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()