1. 程式人生 > >python學習之進度條

python學習之進度條

#文字進度條演示

import time

scale = 50
print("執行開始")
start=time.perf_counter()
for i in range(101):
    a = '|'*i
    b = ''*(scale-i)
    c = ((i/scale)*100)/2
    dur = time.perf_counter()-start
    print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur),end="")
    time.sleep(0.01)
print("\n執行結束")
time.sleep(5)