headers = {"Content-type": "application/json;charset=utf-8", "Authorization": "bearer " + token} data = { # 上游任务id名称 'upstreamTaskId': taskid, 'processTaskName': taskname, 'processTaskDesc': processTaskDesc, 'masterDataId': 2, 'requestType': 1, 'processGroupDataList': processGroupDataList } data = json.dumps(data, ensure_ascii=False) response = requests.post(url, data=data, headers=headers, timeout=600, verify=False).content.decode('utf8')
报错:Python requests.post 发送中文 'latin-1' codec can't encode characters in position 57-62: Body ('元素认知服务') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.
data = json.dumps(data, ensure_ascii=False)改成
data = json.dumps(data, ensure_ascii=False).encode("utf-8")标签:Use,utf,json,62,encode,False,post,data From: https://www.cnblogs.com/shaosks/p/16986898.html