2012-04-09 4 views
0

파이썬 서브 프로세스에서 멈추었습니다. 팝업. 내가 쉘에서 옥타브를 호출 할 때 내가이 시스템은 윈도우 7의 x64를 실행서브 프로세스 모듈을 통해 파이썬에서 옥타브를 호출하십시오.

Shell: octave --eval "1+1" 
GNU Octave, version 3.6.1 
Copyright (C) 2012 John W. Eaton and others. 
This is free software; see the source code for copying conditions. 
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'. 

Octave was configured for "i686-pc-mingw32". 

Additional information about Octave is available at http://www.octave.org. 

Please contribute if you find this software useful. 
For more information, visit http://www.octave.org/help-wanted.html 

Read http://www.octave.org/bugs.html to learn how to submit bug reports. 

For information about changes from previous versions, type `news'. 

ans = 2 

를 얻을 내가 원하는 건

process = subprocess.Popen(['octave.exe', '--eval "1+1"'], stdout=subprocess.PIPE) 
process.wait() 
print(process.stdout.read()) 

와 옥타브 프로세스를 시작하는 것입니다하지만 얻을 모든

octave.exe: unrecognized option '--eval "1+1"' 

usage: octave [-HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE] 
    [--exec-path path] [--help] [--image-path path] [--info-file file] 
    [--info-program prog] [--interactive] [--line-editing] 
    [--no-history] [--no-init-file] [--no-init-path] [--no-line-editing] 
    [--no-site-file] [--no-window-system] [-p path] [--path path] 
    [--silent] [--traditional] [--verbose] [--version] [file] 

입니다 .

답변

0

"subprocess.list2cmdline"은 경로를 작성하는 데 사용됩니다. 공백과 따옴표는 변환됩니다. 따라서 다음 인수 목록이 정확합니다.

args = ["octave.exe", "--eval", '1+1'] 
print(subprocess.list2cmdline(args)) 
관련 문제