我想使用popen
管道
输出我的文件,我该怎么做?
测试.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()
关于python - 如何使用 popen 对输出进行管道传输?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4537259/