美文网首页
测试小白系列---NameError: name 'false'

测试小白系列---NameError: name 'false'

作者: 杨小草_767c | 来源:发表于2020-07-08 14:39 被阅读0次

    当执行代码时提示 NameError: name 'false' is not defined

       def UploadAssignmentAnswer_New(self):
            url = '/ANAService.asmx/UploadAssignmentAnswer_New'
            jsondata = {"session":"A3D3920DE8F9490F96A32F2ADEE7B7A","task_id":23620,"score":0,"duration":344,"is_single":false,"is_done":false,"answer_list":[],"img_json":"[]","question_askes_json":"[]","audio_json":"[]","page":0}
            headers = {'Content-Type': 'application/json'}
            jsonstr = json.dumps(jsondata)  #将json数据转换成字符串
            response = self.client.post(url, data=jsonstr, headers=headers).text
            print(response)
    

    加一行代码执行通过
    false = False

    def UploadAssignmentAnswer_New(self):
        url = '/ANAService.asmx/UploadAssignmentAnswer_New'
        false = False
        jsondata = {"session":"A3D3920DE8F9490F96A32F2ADEE7B7A","task_id":23620,"score":0,"duration":344,"is_single":false,"is_done":false,"answer_list":[],"img_json":"[]","question_askes_json":"[]","audio_json":"[]","page":0}
        headers = {'Content-Type': 'application/json'}
        jsonstr = json.dumps(jsondata)  #将json数据转换成字符串
        response = self.client.post(url, data=jsonstr, headers=headers).text
        print(response)
    

    同理如果传的参数中存在true会提示name 'true' is not defined
    加一行即可解决
    true = True

    相关文章

      网友评论

          本文标题:测试小白系列---NameError: name 'false'

          本文链接:https://www.haomeiwen.com/subject/kekccktx.html