python - 如何在 tqdm 上打印进度条?
问题描述
如何在此 Python 代码的输出中获取进度条?我在这里尝试了一些答案,但没有什么对我有用
我在 Python 3.8.8 上使用“tqdm”库,在 CMD 上使用 Windows 10
这是我尝试过的:
from tqdm import tqdm
LIST = ['user1', 'user2', 'user3']
total = len(LIST)
bar = tqdm(total, desc='Processing')
for u in LIST:
bar.update(LIST.index(u))
这是我不断得到的输出:
Processing: 0it [00:00, ?it/s]
Processing: 3it [00:00, 96.15it/s]
请问有什么帮助吗?
解决方案
from tqdm import tqdm
import time
LIST = ['user1', 'user2', 'user3']
for u in tqdm(LIST):
time.sleep(5)
推荐阅读
- python - 使用 python 获取股票数据 - 不使用 quandl
- azure - 如何在使用 Azure CLI 创建新的 Cosmos DB 集合时指定 10GB 的固定大小
- php - Codeigniter 电子邮件库发送空白电子邮件或 html 源代码
- css - 没有 React-Router 的页面转换
- html - 在 CSS 网格中居中图像
- ajax - 在 laravel 中使用 ajax 进行实时更新
- linux - shell脚本中每个命令执行的延迟
- asp.net-mvc - Bootbox 确认在我的 ASP.net MVC 应用程序中不起作用
- ruby - rspec 未定义方法 `title='
- python - 超过 37 行时 xlwings 无法写入 Excel