可能重複: Bypassing buffering of subprocess output with popen in C or Python 我建立各地應該無限期地運行服務器CMD行腳本的包裝。 我需要做的是在不等待子進程完成的情況下獲取當前的stout。 我的意思是,如果我運行下面的,一切工作正常: ls = Popen(["ls"], stdout=PIPE)
output = ls.s
究竟是什麼標題說: 的subprocess模塊無法使用,因爲這應該在2.4和2.5工作 Shell程序不應催生傳遞論據。 爲了解釋(2),考慮下面的代碼: >>> x=os.system('foo arg')
sh: foo: not found
>>> x=os.popen('foo arg')
sh: foo: not found
>>>
正如你可以看到os.system和os.p