Problems with sys.stdout.write() with time.sleep() in a function

一个人想着一个人 提交于 2019-12-01 05:46:32

You need to flush after writing.

sys.stdout.write('foo')
sys.stdout.flush()
wastetime()
sys.stdout.write('bar')
sys.stdout.flush()
tzot

You should use sys.stderr.write for progress bars; stderr has the (not at all coincidental) advantage of not being buffered, so no sys.stderr.flush calls are needed.

See also this answer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!