python更快写入文件的方法copyfileobj

发布时间 2023-04-09 22:56:40作者: 帅胡
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)