在python代码执行过程中,假如任务量比较大,执行时间较长,除了打印日志或者控制台输出执行数量之外,也可以在控制台展示优雅的进度条用来体现任务执行程度,这里可以使用python的tqdm模块
代码示例1:
import time
from tqdm import tqdm
with tqdm(total=100) as pbar:
for i in range(100):
time.sleep(2)
pbar.update(1)
运行结果1:

代码示例2:
import time
from tqdm import tqdm
for i in tqdm(range(100)):
time.sleep(1)
运行结果2:

具体更多的操作,可以参考下面文章:
https://blog.csdn.net/qq_33472765/article/details/82940843
网友评论