[英]How can you execute python terminal command using a Windows Batch script?
So using Windows batch scripting I know we can open the python interpreter as follows and execute a python script: 因此,使用Windows批处理脚本,我知道我们可以如下所示打开python解释器并执行python脚本:
c:\python27\python.exe c:\documents\python_script.py
In turn, I know it is possible to just open the python interpreter just by typing: 反过来,我知道可以通过键入以下内容来打开python解释器:
c:\python27\python.exe
However, using a batch script is it possible to "communicate" with the python interpreter and send it commands to execute ie: 但是,使用批处理脚本可以与python解释器“通信”并发送命令以执行,即:
c:\python27\python.exe import os
and then to exit from the interpreter as such: 然后像这样从解释器退出:
c:\python27\python.exe exit()
Any insight would be kindly appreciated. 任何见解将不胜感激。
Thankyou 谢谢
您可以使用-c选项
c:\python27\python.exe -c "import sys; print sys.version"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.