Python 异常处理

class  myexception(Exception):
def __init__(self,value):
self.value = value
self.message ='myexception error'

def say():
#name='FreeMan'
try:
raise myexception('test')
'''
#print name
#print 'hello world!'
except NameError as e :
print Exception,e
print e.message
except ArithmeticError as a :
print a.message
'''
except Exception,e:
print e.message
# print 'unknow yichang'
else:
print "Has name"

finally:
print 'get to finally'

say()


posted @ 2016-04-08 14:12  FreeMan1  阅读(155)  评论(0编辑  收藏  举报