2014-05-23 2 views
-1

프로그램 [ex13.py] :명령 프롬프트 양식에서 작동하는 명령을 실행하는 방법 python 셸?

import sys 
a = raw_input("Input 3rd variable:") 
print "The script is called:", sys.argv[0] 
print "Your first variable is:", sys.argv[1] 
print "Your second variable is:", sys.argv[2] 
print "Your third variable is:", a 

는 명령 프롬프트에서 실행 : 3

일이 어떻게 변수는 argv를 제공하여 파이썬 쉘에서이 작업을 실행하는 ex13.py?

+0

가능한 중복 [파이썬에서 외부 명령을 호출 (http://stackoverflow.com/questions/89228/calling-an-를 외부 명령 -에서 - 파이썬) – luk32

답변

0

당신은 당신이 할 수있는 출력을 얻을하려면 다음의

from subprocess import Popen, PIPE 

process = Popen(os.path.dirname("python ex13.py 1 3", shell=True, stdout=PIPE) 

output = process.communicate() 
exit_code = process.wait(); 
관련 문제