简体   繁体   中英

Import variable from Python script to Batch file

I have a python script containing vraibles example.py

"src = komponent/cool,
       komponent/raw"  /* path of source files */

and i have a batch file which needs to import the value of "src" for postporcessing example.bat

--cs-include ='komponent/cool'* --cs-include ='komponent/raw'*

Is there any way to import directly between files (without using any other conversion) ? "PyBat.bat" is one option but i am trying to figure out a better choice dont want to add on one more tool (not specifically)...as my project itself has too different files and interacting source.

Any help is appreciated.. Thank you in advance..!!!

In Python
Create a temp batch file in %TEMP%\\setvars.bat containing SET commands to set environment vars. You could use subprocess.POpen to run an ECHO something > path batch command so that %TEMP% can be used.

In Batch
Call the temp batch file : the vars are now available to use.

Solution is... 1.set a argument in the python itself. 2.call the batch file from python script and along with pass the argument using os.system(cmd) and cmd as a string.

It will set the path itself.

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