import time
scale = 50
print("执行开始".center(scale // 2, "-")) # .center 字符串处理方法,将“-”打印在字符串两侧
start = time.perf_counter() # perf_counter() 计算时间
for i in range(scale + 1):
a = '*' * i
b = '.' * (scale - i)
c = (i / scale) * 100
dur = time.perf_counter() - start # 计算打印文本进度条所消耗的时间
print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c, a, b, dur), end='')
time.sleep(0.1)
print("\n" + "执行结束".center(scale // 2, '-'))
python文本进度条绘制
猜你喜欢
转载自blog.csdn.net/weixin_44940488/article/details/107601213
今日推荐
周排行