python request.post没有值的数据不起作用

问题描述 投票:0回答:1

我如何仅将表单数据的密钥发布到站点本身这样的服务器上?

“

In [1]: from requests import Request

In [2]: req = Request('POST', 'http://www.google.com', data={'json':''}).prepare()

In [3]: req.headers, req.body
Out[3]:
({'Content-Length': '5', 'Content-Type': 'application/x-www-form-urlencoded'},
 'json=')

In [4]: req = Request('POST', 'http://www.google.com', data={'json':None}).prepare()

In [5]: req.headers, req.body
Out[5]: ({'Content-Type': 'application/x-www-form-urlencoded'}, '')

'Content-Length'不能等于密钥的长度,例如4。并且,如何使主体等于“ json”?全部]

我如何仅将表单数据的密钥发布到站点本身这样的服务器上?在[1]中:从请求中导入请求在[2]中:req = Request('POST','http://www.google.com',data = {'json':''})。prepare()在[3]:...

python python-requests
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.