标签:flush import end span sys pre nis print 执行
# coding:utf-8
import sys
import time
total = 50
for i in range(1, total+1):
percentage = round(100/total*i/100, 2)
print(‘\r‘ + ‘%s%%‘ % (str(int(percentage * 100))) + ‘>‘ * (int(percentage * 100)), end=‘‘)
sys.stdout.flush()
time.sleep(0.2)
执行效果:
100%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Process finished with exit code 0
标签:flush import end span sys pre nis print 执行
原文地址:https://www.cnblogs.com/lilyxiaoyy/p/10947173.html