在Python请求库的get方法中使用标头 [英] Using headers with the Python requests library's get method
本文介绍了在Python请求库的get方法中使用标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我最近偶然发现了这个功能强大的库,用于在Python中处理HTTP请求;在此处 http://docs.python-requests.org/en/latest/index.html.
So I recently stumbled upon this great library for handling HTTP requests in Python; found here http://docs.python-requests.org/en/latest/index.html.
我喜欢使用它,但是我不知道如何在我的get请求中添加标题.帮助吗?
I love working with it, but I can't figure out how to add headers to my get requests. Help?
推荐答案
根据 api ,所有标头都可以使用request.get传递:
According to the api, the headers can all be passed in using requests.get:
r=requests.get("http://www.example.com/", headers={"content-type":"text"})
这篇关于在Python请求库的get方法中使用标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文