解决方案是在将参数传递给files参数时使用元组:
import requestsrequests.post('http://example.com/example/asdfas', files={'value_1': (None, '12345'), 'value_2': (None, '67890')})
按预期工作:
'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate, compress', 'Content-Length': '228', 'User-Agent': 'python-requests/2.2.1 CPython/3.3.2 Windows/7', 'Content-Type': 'multipart/form-data; boundary=85e90a4bbb05474ca1e23dbebdd68ed9'--85e90a4bbb05474ca1e23dbebdd68ed9Content-Disposition: form-data; name="value_1"12345--85e90a4bbb05474ca1e23dbebdd68ed9Content-Disposition: form-data; name="value_2"67890--85e90a4bbb05474ca1e23dbebdd68ed9--
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)