Python 进度条 tqdm 的用法

1 tqdm 的安装

pip install tqdm

2 tqdm 的使用

a) tqdm 在 for 循环中的使用

import time
from tqdm import tqdm

for i in tqdm(range(100)):
    time.sleep(0.001)

b) tqdm 在 while 循环中的使用

from tqdm import tqdm

count = 1000
step = 5
pbar = tqdm(total=count)
while count > 0:
    count -= step
    pbar.update(step)

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注