我有一个运行子进程的脚本,如下所示:
child_process = subprocess.Popen(["python", testset['dir'] + testname, \
output_spec_file, plugin_directory],\
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
在那个过程中,我试图插入打印语句,但它们没有出现在标准输出中。我尝试sys.stdout.write()
在该子进程中使用,然后立即使用sys.stduout.read()
,child_process
但它没有捕获输出。
我是 Python 新手,我还没有达到 Python 的复杂程度。我实际上在 C 语言中工作,并且有一些 Python 测试脚本,我不确定如何从子进程中打印出来。
有什么建议么?