【发布时间】:2009-06-15 07:43:13
【问题描述】:
可能重复:
How can I capture the stdout output of a child process?
我正在从 Python 的 bash 中运行类似 cat 的程序:
import os
os.system('cat foo.txt')
如何在 Python 脚本中获取 shell 命令的输出,例如:
s = somefunction('cat foo.txt')
?
UPD:Here 是相关线程。
【问题讨论】: