我想要pipe
我的文件的输出使用popen
, 我怎样才能做到这一点?
test.py:
while True:
print"hello"
a.py :
import os
os.popen('python test.py')
我想使用管道输出os.popen
。
我怎样才能做同样的事情?
首先,os.popen() 已被弃用,请使用 subprocess 模块代替。
你可以这样使用它:
from subprocess import Popen, PIPE
output = Popen(['command-to-run', 'some-argument'], stdout=PIPE)
print output.stdout.read()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)