How to stop running Python .pyw script which doesn't have GUI window?

狂风中的少年 提交于 2021-02-17 05:40:07

问题


I have created a script in python and saved it as .pyw file so that I don't need console to execute the script. I am wondering how to stop the execution once it is running. What I am doing right now is opening the IDLE and closing it and it seems to work. I am sure there is a better way of doing this. Can somebody advise me about this?


回答1:


As it says in the docs

The Python installer automatically associates .py files with python.exe so that a double-click on a Python file will run it as a script. The extension can also be .pyw, in that case, the console window that normally appears is suppressed.

The .pyw extension is really meant to be used by Python GUIs. Since they create their own windows, the console window isn't required. If a .pyw script doesn't create any GUI windows, killing the python process is the only way to stop execution.

If you don't want to use the console to run your script (using the .py extension), just double-click on it.



来源:https://stackoverflow.com/questions/8718064/how-to-stop-running-python-pyw-script-which-doesnt-have-gui-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!