try:
spa
a = bio
b = cast
except Exception,data:test
print Exception,":",dataobject
'''輸出:<type 'exceptions.Exception'> : local variable 'b'
exception
referenced before assignment '方法
try:
call
a = b異常
b = cco
except:
print traceback.print_exc()
'''輸出: Traceback (most recent call last):
File "test.py", line 20, in main
a = b
UnboundLocalError: local variable 'b
try:
a = b
b = c
except:
info = sys.exc_info()
print info
print info[0]
print info[1]
'''輸出:
(<type 'exceptions.UnboundLocalError'>, UnboundLocalError("local
variable 'b' referenced before assignment",),
<traceback object at 0x00D243F0>)
<type 'exceptions.UnboundLocalError'>
local variable 'b' referenced before assignment
'''