我如何在Python标头后发送空白行

问题描述 投票:0回答:1
Transfer-Encoding : chunked
Host: example.com
User-Agent: Smuggler/v1.0
Content-Length: 83

0

GET <URL> HTTP/1.1
X: X

您可以在正文中看到,我想在Content-Length之后和0之后发送一些黑线我试过了headers = {'user-agent':'bot','\ r \ n'}在标头后添加\ r \ n,但它不起作用我的代码

import request 

url = "http://example.com" 
headers = {'user-agent':'firefox',\r\n ,'Content-type':'application/json'}
response = request.get(url,headers=headers)
python
1个回答
0
投票

我无法发表评论,因此我必须在此处提供链接。 This shows how to add line breaks。您没有提供任何代码,因此很难提供正确的帮助。

看到代码后进行编辑:

您必须将'\r\n'或更确切地说是'\n'放在引号内。

示例:

a='\n'*3
print(f'hello{a}world')
### Outputs ###
# hello
# 
# 
# world
© www.soinside.com 2019 - 2024. All rights reserved.