可以python 3.2下载http.client.HTTPConnection大文件



python 3.2上的http.client.HTTPConnection可以下载大约1G的大文件吗?我得到类HTTPResponse的源当我读取内容时,所有数据将保存到变量中并返回,变量是否可以将1G数据保存到内存中?

我想保存数据以订购套接字作为隧道,我没有看到yield关键字在HTTPResponse上的任何地方?

http.client.HTTPConnection可以运行这个任务吗?谢谢:D

分块阅读回答。它可以下载它们

import http.client
conn = http.client.HTTPConnection("www.python.org")
conn.request("GET", "/index.html")
r1 = conn.getresponse()
print(r1.status, r1.reason)
data1 = r1.read()  # This will return entire content.
# The following example demonstrates reading data in chunks.
conn.request("GET", "/index.html")
r1 = conn.getresponse()
while not r1.closed:
    print(r1.read(200)) # 200 bytes

相关内容

最新更新