[英]Sending arguments from Batch file to Python script
I'm running Python 3.2 on Win XP. 我在Win XP上运行Python 3.2。 I run a python script thru a batch file via this:
我通过这个运行一个python脚本通过批处理文件:
C:\\Python32\\python.exe test.py %1
%1
is an argument that i pass to do some processing in the python script. %1
是我传递给python脚本中的一些处理的参数。
I have 2 variables in the batch file that I also want to send as arguments to the python script. 我在批处理文件中有2个变量,我也想将它们作为参数发送到python脚本。
set $1=hey_hi_hello
set $2=hey_hi
I want to be able to do something like this if possible: 如果可能的话,我希望能够做到这样的事情:
C:\\Python32\\python.exe test.py %1 $1 $2
And then retrieve these argiments in the python script via sys.argv[2]
and sys.argv[3]
然后通过
sys.argv[2]
和sys.argv[3]
在python脚本中检索这些argiments
Would appreciate any help with this. 非常感谢任何帮助。 Thank you.
谢谢。
your_script.bat: your_script.bat:
set VAR_1=this
set VAR_2=that
python your_script.py %1 %VAR_1% %VAR_2%
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.