python sys.exit not working in try [duplicate]
问题 This question already has answers here : Why is “except: pass” a bad programming practice? (16 answers) Closed 5 years ago . Python 2.7.5 (default, Feb 26 2014, 13:43:17) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> try: ... sys.exit() ... except: ... print "in except" ... in except >>> try: ... sys.exit(0) ... except: ... print "in except" ... in except >>> try: ... sys.exit(1) ... except: ... print