简体   繁体   中英

Sending arguments from Batch file to Python script

I'm running Python 3.2 on Win XP. I run a python script thru a batch file via this:

C:\\Python32\\python.exe test.py %1

%1 is an argument that i pass to do some processing in the python script.

I have 2 variables in the batch file that I also want to send as arguments to the python script.

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]

Would appreciate any help with this. Thank you.

your_script.bat:

set VAR_1=this
set VAR_2=that

python your_script.py %1 %VAR_1% %VAR_2%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM