def terminal_animation():
print("让我们看看会不会被覆盖....")
count = 0
length=20
for i in range(length):
point = ['/','-','\\','|']
r = '\r[%s%s]%d%s' % ('#'*i,' '*(length-i),int(((i+1)/length)*100),point[count])
sys.stdout.write(r)
sys.stdout.flush()
count += 1
if count > int(len(point)-1):
count = 0
time.sleep(0.1)
print("\n")
1.把代码中的"\r"去掉:
2.把代码中的flush去掉:
理论上不能实时刷新结果可以......可能操作系统有自带刷新