首页 > 代码库 > python handle exception

python handle exception

1. handle exception

import systry:     a=1/1except 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/0except Exception as e :     print (type(e))     print(e.args)     print (e)

 

python handle exception