【发布时间】:2019-06-23 19:46:44
【问题描述】:
我正在尝试在下载带有 python 请求库的文件时使用 tqdm 显示进度条。但它不显示进度条。它显示了这个
22964708: 2804it [00:13, 204.17it/s]
这是我的代码:
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open("downloads/" + name, 'wb') as f:
for chunk in tqdm(r.iter_content(chunk_size=8192),r.headers.get("content-length")):
if chunk:
f.write(chunk)
【问题讨论】:
-
能否请您使用您的
url进行测试? :) -
@B.Gees 当然:hw15.cdn.asset.aparat.com/aparat-video/…
-
并且你的
name没有定义;) -
@B.Gees 名字无关紧要。它可以是“askjdajskd”。
标签: python python-3.x python-requests tqdm