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

    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')

 

posted on 2021-01-12 19:55  我和你并没有不同  阅读(63)  评论(0编辑  收藏  举报