python更快写入文件的方法copyfileobj
import requests import shutil def download_file(url, path): with requests.get(url, stream=True) as r: with open(path, 'wb') as f: shutil.copyfileobj(r.raw, f)
import requests import shutil def download_file(url, path): with requests.get(url, stream=True) as r: with open(path, 'wb') as f: shutil.copyfileobj(r.raw, f)