在Python中,如何在标题后发送一些空行

2024-05-19 01:37:49 发布

您现在位置:Python中文网/ 问答频道 /正文

Transfer-Encoding : chunked
Host: example.com
User-Agent: Smuggler/v1.0
Content-Length: 83

0

GET <URL> HTTP/1.1
X: X

正如你们在正文中看到的,我想在内容长度和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)

Tags: comhosturlexamplerequestcontentencodingagent
1条回答
网友
1楼 · 发布于 2024-05-19 01:37:49

我不能评论,所以我必须在这里提供链接This shows how to add line breaks。您没有提供任何代码,因此很难提供正确的帮助

查看代码后编辑:

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

例如:

a='\n'*3
print(f'hello{a}world')
### Outputs ###
# hello
# 
# 
# world

相关问题 更多 >

    热门问题