代码思想: 通过for循环逐渐增加加载进度,使用\r用新的内容覆盖之前的内容
import time
total
=20
print("开始".center
(total
,'-'))
t
=time
.clock
()
for i
in range(total
+1):
OK
='*'*i
NO
='·'*(total
-i
)
add
=(i
/total
)*100
t
=time
.clock
()
print("\r{:^3.0f}%[{}{}]{:.2f}s".format(add
,OK
,NO
,t
),end
='')
time
.sleep
(0.05)
print("\n"+"结束".center
(total
,'-'))
结果运行图:
转载请注明原文地址: https://lol.8miu.com/read-30983.html