干净地退出python脚本
我正在尝试退出python脚本,但不会出现令人讨厌的错误消息:干净地退出python脚本,python,exit-code,Python,Exit Code,我正在尝试退出python脚本,但不会出现令人讨厌的错误消息: Traceback (most recent call last): File "<pyshell#27>", line 3, in <module> sys.exit() SystemExit 注意:解决方案不一定要接近此代码,这只是我在Python控制台(在Windows或Linux下)运行此程序时尝试过的一个示例。当我使用sys.exit(-1)时,没有收到任何类型的错误消息。但是,iPy
Traceback (most recent call last):
File "<pyshell#27>", line 3, in <module>
sys.exit()
SystemExit
注意:解决方案不一定要接近此代码,这只是我在Python控制台(在Windows或Linux下)运行此程序时尝试过的一个示例。当我使用
sys.exit(-1)
时,没有收到任何类型的错误消息。但是,iPython会给我
An exception has occurred, use %tb to see the full traceback.
SystemExit: -1
我怀疑您看到错误消息是因为您在某种IDE中工作,是这样吗?您运行的是什么系统?您是否通过IDE运行脚本,例如IDLE?重复@Joel,是IDLE。这会有所不同吗?@shuranewindows7,python2.7.2。是的,这是IDE。谢谢
An exception has occurred, use %tb to see the full traceback.
SystemExit: -1