printbob.py:获取python脚本的输出从Python脚本中
import sys
for arg in sys.argv:
print arg
getbob.py
import subprocess
#printbob.py will always be in root of getbob.py
#a sample of sending commands to printbob.py is:
#printboby.py arg1 arg2 arg3 (commands are seperated by spaces)
print subprocess.Popen(['printbob.py', 'arg1 arg2 arg3 arg4']).wait()
x = raw_input('done')
我得到:
File "C:\Python27\lib\subprocess.py", line 672, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 882, in _execute_child
startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application
我在做什么错在这里? 我只想得到另一个python脚本内的另一个python脚本的输出。 我是否需要调用cmd.exe,或者我可以运行printbob.py并将命令发送给它?
回溯(最后最近一次调用): 文件 “”,1号线,在 subprocess.STDIN AttributeError的: '模块'对象没有属性'STDIN' –
MistahX
2011-05-22 04:58:51
意思标准输出 - 固定。 – rfw 2011-05-22 05:03:55
我不得不将arg1 arg2分成不同的comman分隔字符串,就像'['python','printbob.py','arg1','arg2']' – Quinma 2014-01-17 22:44:26