0
点赞
收藏
分享

微信扫一扫

download-large-file-in-python-with-requests

萍儿的小确幸 2022-06-01 阅读 118

def _http_download(url, target):
        # https://stackoverflow.com/questions/16694907/download-large-file-in-python-with-requests
        with requests.get(url, stream=True) as r:
            r.raise_for_status()
            with open(target, 'wb') as f:
                for chunk in r.iter_content(chunk_size=8192): 
                    # If you have chunk encoded response uncomment if
                    # and set chunk_size parameter to None.
                    #if chunk: 
                    f.write(chunk)

 

解压:
shutil.unpack_archive(down_file, app_work_dir, format='tar')

 

举报

相关推荐

0 条评论