没有理由一行一行地工作(小块并且需要Python来为您找到行尾!-),只需将其分成更大的块即可,例如:
# from urllib2 import urlopen # Python 2from urllib.request import urlopen # Python 3response = urlopen(url)CHUNK = 16 * 1024with open(file, 'wb') as f: while True: chunk = response.read(CHUNK) if not chunk: break f.write(chunk)
尝试各种CHUNK尺寸,找到适合您需求的“最佳位置”。



