python 下载url函数

import requests
import shutil


def download_file(url, local_filename):
    """
    :param url: url连接
    :param local_filename: 下载后保存文件名字
    """
    with requests.get(url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
posted @ 2022-09-05 09:09  不能说的秘密  阅读(32)  评论(0编辑  收藏  举报