python - python 2.7 中的 HTTP 2 请求

标签 python http http2

在python中向HTTP/1和HTTP/2发出请求有什么不同吗?

我可以像在 python 中调用 HTTP/1.x

url = 'http://someURL'
values = {'param1' : 'key',
          'param2' : 'key2'}
data = urllib.urlencode(values)
print data
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page

默认情况下 python 支持制作 HTTP/2 还是我应该添加任何额外的东西。

最佳答案

作为引用,截至 2019 年,另一个支持 HTTP/2 的库是 HTTPX .

HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support for both HTTP/1.1 and HTTP/2.

这至少需要 Python 3.6。然而,在 2020 年撰写本文时,Python 2 已经停产,因此 Python 3.6 对任何用户来说都应该没问题。

关于python - python 2.7 中的 HTTP 2 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34570991/

相关文章:

http - WWW 或非 WWW 的技术/编程/非 SEO 利弊?

jquery - 通过 AJAX 发送图像文件。 request.FILES 为空?

node.js - HTTP2 - 如何拥有类似 WebSocket 的功能(Keep-Alive、EventSource 等)

python - 如果用户在一段时间内不活动,则使用户 session 过期,并在数据库中记录其 session 开始和结束时间

python - 如何在 Python 3 中将具有属性的对象转换为不带 "_"的 JSON?

python - Visual Studio - "The environment IronPython|2.7-32 appears to be incorrectly configured or missing"

Python 请求使用 keep-alive 加速

python - 与 Pi 和 Arduino 的串行通信

http - 具有 HTTP2 前端和 HTTP1.1 后端的 HAProxy

http2 - Kong - 通过 HTTP/2 连接到上游