Skip to main content
 首页 » 编程设计

python之如何删除 Python IDLE 中的 exit(0) 弹出窗口

2024年10月24日13fff_TT

我正在尝试在 Python IDLE 上运行一些代码,但是当我使用 exit() 时,我收到了一个弹出窗口。如何删除此弹出窗口?

print "hi" 
exit(-1) 

请您参考如下方法:

使用 sys 模块中的 exit()。

import sys 
 
# your cool code here 
 
sys.exit(0) # stops the program without a pop-up 

例如在 if 中:

import sys 
 
x = 2 
if x > 1: 
    print "x > 1" 
    sys.exit() 
else: 
    print x