更新时间:2022-12-27 11:27:20
通过python -u标志取消缓冲标准输出
Pass python the -u flag for unbuffering stdout
nohup python -u test.py &
Python将以其他方式缓冲stdout.这不需要更改代码.
Python will buffer stdout otherwise. This doesn't require a code change.
在手册页中:
-u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout
and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file-object
iterators ("for line in sys.stdin") which is not influenced by this option. To work around this, you will want
to use "sys.stdin.readline()" inside a "while 1:" loop.