1. handle exception
import sys try: a=1/1 except Exception, e: print "failed", sys.exc_info()[0] else: print "no exception" finally: print "execute final"
2. print exception
try: raise Exception("aaa","bbb") #a=1/0 except Exception as e : print (type(e)) print(e.args) print (e)
时间: 2024-10-11 23:08:17