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)

 

posted on 2023-04-09 22:54  帅胡  阅读(35)  评论(0编辑  收藏  举报

导航