问题
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 withpython.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