python实时输出

来源:互联网 发布:微星网络唤醒bios设置 编辑:程序博客网 时间:2024/05/29 15:12

对于python脚本,输出语句

print 'hello'

与python语句是一致的

sys.stdout.write('hello'+'\n')

这里仅仅只是将数据输出到了缓冲区,还没有到shell终端

print 'hello'sys.stdout.flush()

这样就可以直接将输出数据输出到终端。
脚本运行时间较短还可以,但是较长的时候,则需要实时输出数据,监控log日志的输出。

0 0