长虫山小木屋

没有谁会为你踏雪而来 喜欢的风景要躬亲筚路

  博客园  :: 首页  :: 新随笔  :: 联系 ::  :: 管理
import time
scale=100
print("执行开始".center(scale+28,'-'))
start = time.perf_counter()
for i in range(scale+1):
    a = '*' * i
    b = '.' * (scale - i)
    c = (i/scale)*100
    t = time.perf_counter() - start
    print("\r任务进度:{:>3.0f}% [{}->{}]消耗时间:{:.2f}s".format(c,a,b,t),end="")
    time.sleep(0.03)
print("\n"+"执行结束".center(scale+28,'-'))

执行结果:

--------------------------------------------------------------执行开始--------------------------------------------------------------
任务进度:100% [****************************************************************************************************->]消耗时间:3.26s
--------------------------------------------------------------执行结束--------------------------------------------------------------

 

posted on 2021-05-12 23:40  长虫山小木屋  阅读(131)  评论(0编辑  收藏  举报