【发布时间】:2018-08-11 10:11:52
【问题描述】:
from sys import argv, stdout as cout
from time import sleep as sl
print("Rewinding.......",end = '') # If end is given output isn't flushed. But why?
cout.flush()
for i in range(0,20):
sl(0.2)
print(".",end='',flush = True) #No output is printed if flush wasn't specified as true.
print("Done") #Output is by default flushed here
当我指定结束和睡眠时,我注意到输出直到下一次打印才被刷新,默认情况下它被刷新。
为什么会这样?我不得不手动刷新输出。
【问题讨论】:
标签: python python-3.x stdout flush