class myException(Exception): def __init__(self,error,msg): self.args = (error,msg) self.error = error self.msg = msg try: raise myException(1,‘my exception‘) except Exception as e: print str(e)
简单的自定义异常
原文:http://www.cnblogs.com/predator-wang/p/4167134.html