调用python脚本时让stdout不缓冲

来源:互联网 发布:淘宝主播秒杀软件下载 编辑:程序博客网 时间:2024/05/16 15:19
 

在其它代码中调用python脚本时,因为stdout由行缓冲变成了块缓冲(block buffered),导致不能及时看到python脚本print的内容。

python -u选项指定stdin, stdout, stderr为unbuffered,对于在其他程序中调用python脚本很有用 :)