python-requests的post

python-requests的post

python requests Content-Length

How not to let python requests calculate content-length and use the provided one? - Stack Overflow

from requests import Request, Session

s = Session()

req = Request('POST', url, data=data, headers=headers)
prepped = req.prepare()

# do something with prepped.headers
prepped.headers['Content-Length'] = your_custom_content_length_calculation()

resp = s.send(prepped, ...)

requests post 修改了Content-Length

官方文档:
Advanced Usage — Requests 2.26.0 documentation

上一篇:OneNote快捷键


下一篇:爬虫与Python:(三)基本库的使用——3.网络请求库之request使用介绍