更新时间:2023-12-04 10:34:46
在 Python 3 中,print
可以采用可选的 flush
参数:
In Python 3, print
can take an optional flush
argument:
print("Hello, World!", flush=True)
在 Python 2 中你必须做的
In Python 2 you'll have to do
import sys
sys.stdout.flush()
在调用print
之后.默认情况下,print
打印到 sys.stdout
(有关文件对象的更多信息,请参阅文档.
after calling print
. By default, print
prints to sys.stdout
(see the documentation for more about file objects).