1
我有兩個文件:Python標準輸出和子
run.py
import subprocess
import time
while True:
time.sleep(1)
print 'hello'
proc = subprocess.call(['./writer.sh'])
writer.sh(CHMOD 777'd)
#!/bin/sh
echo 'write something here'
,我很困惑通過以下輸出:
$ python run.py
hello
write something here
hello
write something here
hello
write something here
....
$ python run.py | tee out.log
write something here
write something here
(hello disappears)
....
$ python run.py > out.log
# Nothing, but out.log has the following:
write something here
write something here
write something here
write something here
hello
hello
hello
hello
... # and the two basically "expand" the longer I run this (instead of appending)
什麼我發生什麼事了,我怎樣才能像第一個命令一樣輸出所有內容?
啊,並且tee和重定向到一個文件使得緩衝區不是一行一行,而只是在每一行上運行一次tty。謝謝! – theicfire