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

当执行代码时提示 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' is not defined)