tqdm

from tqdm import tqdm
for i in tqdm(range(1, 60)):
"""
代码
"""
time.sleep(0.05)

​ 美化:

from tqdm import tqdm
import time

pbar = tqdm(range(10))
for idx, i in enumerate(pbar):
time.sleep(0.3)
acc_ = i*10
loss = 1/((1+1)*10)
pbar.set_description(f'Training [{idx+1}]')
pbar.set_postfix(dict(acc=f'{acc_}%', loss=f'{loss:.3f}'))

alive_progress

​ alive_progress是一个动态的实时显示进度条库,详细的用法可以参考下方官方文档:https://pypi.org/project/alive-progress/#description

from alive_progress import alive_bar

with alive_bar(len(range(100))) as bar:
for item in range(100): # 遍历任务
bar() # 显示进度
"""
代码
"""
time.sleep(0.05)

progressbar

https://pypi.org/project/progressbar/#description

import progressbar
p = progressbar.ProgressBar()

for i in p(range(100)):
"""
代码
"""
time.sleep(0.05)