Python script to Batch file

后端 未结 5 474
半阙折子戏
半阙折子戏 2021-01-03 10:26

I have a batch file that runs a python script. I am running Python 3.2. I want to send a variable like an integer or string from the python script back to the batch file, is

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-03 10:44

    If a int is enough for you, then you can use

    sys.exit(value)
    

    in your python script. That exits the application with a status code of value

    In your batch file you can then read it as the %errorlevel% environment variable.

提交回复
热议问题