【发布时间】:2011-08-09 21:38:17
【问题描述】:
我试过了,但是当我尝试打印这些参数时,它没有返回任何值。 我在下面提交我的代码:
运行外部python程序的script1 (script2)
#(...)
proc = subprocess.Popen(['export PYTHONPATH=~/:$PYTHONPATH;' +
'export environment=/path/to/environment/;' +
'python /path/to/my/program/myProgram.py',
'%(date)s' %{'date':date}, '%(time)s' %{'time':time}],
stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
#(...)
script1 正在运行的script2
#(...)
print sys.argv[0] #prints the name of the command
print sys.argv[1] #it suppose to print the value of the first argument, but it doesn't
print sys.argv[2] #it suppose to print the value of the second argument, but it doesn't
#(...)
【问题讨论】:
-
你试过使用
shlex.split吗? -
不,不是真的,这会有帮助吗?
标签: python subprocess pipe popen