Can a batch file execute commands within a python shell? -
can use batch file start python shell , execute commands? know that
python
will start python shell, batch file containing
python 1+1
will first run python, , when quit python attempt run 1+1. not execute commands within python shell.
after little searching around, managed find this website has method this. see on website, need is:
@setlocal enabledelayedexpansion && python -x "%~f0" %* & exit /b !errorlevel! #start python code here print "hello world"
this didn't work me, thought might help.
i haven't been able find other source says it's possible.
just thought of else haven't tested. combined bear's answer , mine.
@for /f "skip=1 delims=" %i in (%0) @python -c "%i" #start python here.
however, other method should used.
Comments
Post a Comment