1, 下载,肯定要看进度
优秀的 progress bar
tqdm
安装
sudo python3 -m pip install tqdm
1.1, 加环境变量
#!/usr/bin/python3
from tqdm import tqdm
import requests
上一步安装 tqdm 的是 python3 ,
python3 关联到了 tqdm 这个库,
不加环境变量,
走默认的 python 2.7,
不是在 python 2.7 上,安装的这个库 tqdm
2 , 下载代码
这个文件,700 M 左右
走文件流,下载的速度,比 Chrome 快多了
走 Chrome 下载,老是失败
#!/usr/bin/python3
from tqdm import tqdm
import requests
url = 'https://static.realm.io/downloads/swift/realm-swift-10.1.1.zip'
# Streaming, so we can iterate over the response.
response = requests.get(url, stream=True)
total_size_in_bytes = int(response.headers.get('content-length', 0))
block_size = 1024 #1 Kibibyte
progress_bar = tqd

本文介绍了如何使用Python下载大文件,并且在下载过程中显示进度条。通过tqdm库实现进度条功能,确保下载过程可见。同时,文章提到了避免使用Chrome下载,因为直接使用文件流方式的Python下载速度更快且更稳定。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



