gpt4 book ai didi

python - python请求中默认的请求头是什么

转载 作者:太空狗 更新时间:2023-10-30 01:11:14 25 4
gpt4 key购买 nike

我正在使用 requests将我的数据发布到 URL。我需要知道我的请求发送的 header 是什么?

import requests
conf_json = {"key_1": "value_1", "key_2": "value_2"}
r = requests.post(API_URL, json=conf_json)

我可以通过r.headers获取响应头,但我需要请求头,但我不知道如何获取它。你能指导我吗?

最佳答案

import requests
conf_json = {"key_1": "value_1", "key_2": "value_2"}
r = requests.post(API_URL, json=conf_json)

# get request headers
print(r.request.headers)

关于python - python请求中默认的请求头是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52570933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com