【发布时间】:2012-09-29 08:05:23
【问题描述】:
我有一个运行子进程的脚本,如下所示:
child_process = subprocess.Popen(["python", testset['dir'] + testname, \
output_spec_file, plugin_directory],\
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
在该过程中,我尝试插入打印语句,但它们没有出现在标准输出中。我尝试在该子进程中使用sys.stdout.write(),然后在child_process 之后使用sys.stduout.read(),但它没有捕获输出。
我是 Python 新手,我还没有达到 Python 的复杂程度。我实际上在 C 语言中工作,并且有一些 Python 测试脚本,我不确定如何从子进程中打印出来。
有什么建议吗?
【问题讨论】:
-
你为什么要在一个新的解释器中运行你的 python 脚本,而不是简单地将它作为一个模块使用?
标签: python subprocess