>>>>>> try:
raise Exception("a", "b")
except Exception,e:
print e
finally:
print "final
"
('a', 'b')('a', 'b')
final
>>>>>> deal with muti exception >>>>>> try:
raise EOFError("aa", "bb")
except RuntimeError, e:
print "[RuntimeErro]: ", e
except EOFError, e:
print "[EOFError]: ", e
except Exception, e:
print "[Error]: ", e
finally: [EOFError]: ('aa', 'bb')
final
>>>>>>
get error information using sys。
Code
>>>>>> import sys
>>>>>> try:
raise RuntimeError("the runtime error raised")
except:
print sys.exc_info()
(<type 'exceptions.RuntimeError'>, RuntimeError('the runtime error raised',), <traceback object at 0x00DC5CB0>)
>>>>>>
print "final
" --
we drink green tea
