printbob.py:salida del script en Python desde dentro de un script en 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')
me sale:
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
¿Qué estoy haciendo mal aquí? Solo quiero obtener el resultado de otro script de python dentro de otro script de python. ¿Debo llamar a cmd.exe o puedo ejecutar printbob.py y enviarle comandos?
Rastreo (llamada más reciente pasado): Archivo "", línea 1, en subprocess.STDIN AttributeError: 'módulo' el objeto no tiene atributo 'STDIN' –
MistahX
Significa STDOUT - corregido. – rfw
Tuve que separar arg1 arg2 en diferentes cadenas de coman separado como '['python', 'printbob.py', 'arg1', 'arg2']' – Quinma