import time
scale=10
print("------執行開始------")
for i in range(scale+1):
a=''i
b='.'(scale-i)
c=(i/scale)100
print("{:^3.0f}%[{}->{}]".format(c,a,b))
time.sleep(0.1)
print("------執行結束------")
輸出:
------執行開始------
0 %[->..........]
10 %[->.........]
20 %[->........]
30 %[**->.......]
40 %[****->......]
50 %[*****->.....]
60 %[******->....]
70 %[*******->...]
80 %[********->..]
90 %[*********->.]
100%[**********->]
------執行結束------
代碼為本人親自敲寫,都可以運行,轉載的朋友請注明出處http://www.lxweimin.com/writer#/notebooks/35294278/notes/43538066,謝謝!