如何在命令提示符形式的pythonshell中运行命令?
程序[ex13.py]:如何在命令提示符形式的pythonshell中运行命令?,python,shell,Python,Shell,程序[ex13.py]: 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 在命令提示符下执行: ex13.py
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
在命令提示符下执行:
ex13.py 1 3
如何通过提供argv从python shell运行此命令?如果要获得输出,可以执行以下操作:
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();
可能重复的