是否有可能在运行结束后从我的 python 代码/脚本中以某种方式退出 Windows 下的 Python IDLE?
我试过类似的方法:
import sys
sys.exit(0) # or exit(1)
没用。可能只退出正在运行的 python 脚本的当前“进程”。 非常感谢
请您参考如下方法:
如果您可以从命令行运行 IDLE(或编辑您的快捷方式),我在 IDLE 帮助中找到了这个。
If IDLE is started with the -n command line switch it will run in a
single process and will not create the subprocess which runs the RPC
Python execution server.
这似乎暗示脚本正在内部 IDLE 运行。我做了一个快速测试脚本,调用 exit() 弹出了一个要求终止程序的框。点击yes,脚本和IDLE都退出了。希望能有所帮助。
