Calling batch file that calls python script that uses parameter defined in initial batch file -
this question has answer here:
- how read/process command line arguments? 16 answers
i've 2 batch files, a.bat , b.bat, python script c.py
a.bat looks this:
call b.bat hello
now of course, if use %1 in b.bat, batch file view value "hello". now, if have b.bat call c.py, need c.py able recognize %1 hello, same way b.bat recognizes that.
of course, i've tried writing in b.bat:
call c.py %1
and using %1 in c.py in batch file, did not work. don't know if means can't use %1 parameter or if can't use parameter of type in python, or both. so, how able use parameter in c.py defined in a.bat?
to access parameters in python, use:
import sys print(sys.argv[1]) # view first parameter, similar %1 in .bat
Comments
Post a Comment