【发布时间】:2013-05-21 14:07:29
【问题描述】:
在我的 Python 代码中,我有
executable_filepath = '/home/user/executable'
input_filepath = '/home/user/file.in'
我想分析我在 shell 中从命令得到的输出
/home/user/executable </home/user/file.in
我试过了
command = executable_filepath + ' <' + input_filepath
p = subprocess.Popen([command], stdout=subprocess.PIPE)
p.wait()
output = p.stdout.read()
但它不起作用。我现在能想到的唯一解决方案是创建另一个管道,并通过它复制输入文件,但必须有一个简单的方法。
【问题讨论】: