简体   繁体   English

如何在 tqdm 上打印进度条?

[英]How can i print the progress bar on tqdm?

How can I get the progress bar at the output in this Python code?如何在此 Python 代码中的 output 处获得进度条? I tried some answers here, but nothing works well for me我在这里尝试了一些答案,但没有什么对我有用

I used "tqdm" library on Python 3.8.8, Windows 10 on CMD我在 Python 3.8.8 上使用了“tqdm”库,在 CMD 上使用了 Windows 10

Here is what I tried:这是我尝试过的:

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

Here is the output that I keep getting:这是我不断得到的 output:

Processing: 0it [00:00, ?it/s]
Processing: 3it [00:00, 96.15it/s]

Any help please?请问有什么帮助吗?

from tqdm import tqdm
import time

LIST = ['user1', 'user2', 'user3']

for u in tqdm(LIST):
    time.sleep(5)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM