Python scripts (files with the extension .py) will be executed by
python.exe by default. This executable opens a terminal, which stays
open even if the program uses a GUI. If you do not want this to
happen, use the extension .pyw which will cause the script to be
executed by pythonw.exe by default (both executables are located in
the top-level of your Python installation directory). This suppresses
the terminal window on startup.
You can also make all .py scripts execute with pythonw.exe, setting
this through the usual facilities, for example (might require
administrative rights):
https://docs.python.org/2/using/windows.html
因此,在实践中,唯一的区别是一个保留控制台窗口,另一个则不保留。对于*.pyw,最明显的用法是使用GUI应用程序,因为具有独立GUI的应用程序显然不需要或不需要控制台窗口。
python.exe和pythonw.exe之间存在一些细微的实现差异,请参见https://stackoverflow.com/a/30313091/3703989
相关问题 更多 >
编程相关推荐