我正在尝试发送python post请求,但是当我添加到标头"Content-Length" : 67
时出现错误:
requests.exceptions.InvalidHeader:
Value for header {Content-Length: 67} must be of type str or bytes, not <class 'int'>
当我尝试以字符串形式发送时,出现超时错误。 我必须注意内容的长度。
这是代码的一部分:
url_enter = 'some url..'
data_login = {some data login}
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;"
"q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language": "en-US;q=0.8,en;q=0.7",
"User-Agent": "some user agent",
"Accept-Encoding": "gzip, deflate",
"Content-Length": 67
}
res = requests.post(url_enter, headers=headers, cookies=data_login, timeout=7)
print(res.headers)