结论:请求头不要带内容类型
原来的代码:
headers={'Content-Type': 'application/json', 'Authorization': token,...}
requests.post(url=url, files=files, data=data, headers=headers,verify=False)
报错了,搜索了一波,然后修改一版,还是报错
headers={'Content-Type': 'application/json', 'Authorization': token,...}
headers["Content-Type"] = 'multipart/form-data'
requests.post(url=url, files=files, data=data, headers=headers,verify=False)
最后对比了一下postman的请求头和python发出去的请求头,想着去掉内容类型试一下
headers={'Content-Type': 'application/json', 'Authorization': token,...}
headers.pop("Content-Type")
requests.post(url=url, files=files, data=data, headers=headers,verify=False)
请求成功,证明我的想法是对的,之前看资料的时候,看到说请求类型如果是file,会自带这个内容类型,报错应该是自己声明了给覆盖掉了或者怎样,不管怎样问题解决了就行