[英]Batch runs python script.. how to close cmd window at end?
I have batch file that runs python script.我有运行 python 脚本的批处理文件。 But, once python script finishes, cmd stays open.. How can I close it?
但是,一旦 python 脚本完成,cmd 就会保持打开状态。我该如何关闭它?
Thank you!谢谢!
Edit: .bat script looks something like this:编辑:.bat 脚本如下所示:
C:\Users\USER\AppData\Local\Programs\Python\Python36\python.exe C:\Users\USER\Documents\Code\python\some-dir\script.py %1 %2
And then python script runs, and once it ends, cmd window from batch file remains open.. Can I close it somehow from python script itself or something?然后python脚本运行,一旦结束,批处理文件中的cmd窗口保持打开状态..我可以从python脚本本身或其他东西以某种方式关闭它吗?
Edit2: Nevermind, figured it out. Edit2:没关系,想通了。 You can just add
exit
at end of the batch file, and it will run once the python script ends您可以在批处理文件的末尾添加
exit
,它会在 python 脚本结束后运行
Just create a line with the exit
command at the end of the batch file.只需在批处理文件的末尾用
exit
命令创建一行。 That will close the cmd window when it reaches the end.这将在结束时关闭 cmd 窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.