gpt4 book ai didi

python - 将 header 与 Python 请求库的 get 方法一起使用

转载 作者:IT老高 更新时间:2023-10-28 21:06:25 25 4
gpt4 key购买 nike

所以我最近偶然发现了这个在 Python 中处理 HTTP 请求的优秀库;在这里找到 http://docs.python-requests.org/en/latest/index.html .

我喜欢使用它,但我不知道如何将 header 添加到我的 get 请求中。帮忙?

最佳答案

根据API , headers 都可以用 requests.get() 传入:

import requests
r=requests.get("http://www.example.com/", headers={"Content-Type":"text"})

关于python - 将 header 与 Python 请求库的 get 方法一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6260457/

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