【发布时间】:2012-06-01 09:01:30
【问题描述】:
我正在尝试退出 python 脚本,但不会出现烦人的错误消息:
Traceback (most recent call last):
File "<pyshell#27>", line 3, in <module>
sys.exit()
SystemExit
我尝试了很多东西,但都没有奏效。这是一个例子:
while True:
print "hi", #this just tests to see if I have exited.
try:
sys.exit()
except SystemExit:
print "Exited"
注意:解决方案不必与此代码接近,这只是我尝试过的一个示例
【问题讨论】:
-
你在什么系统上运行?
-
您是否通过 IDE(例如 IDLE)运行脚本?
-
@Joel,是的空闲。这应该有所作为吗?
-
@Shurane Windows 7,python 2.7.2。