简单的自定义异常

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)

原文地址:https://www.cnblogs.com/predator-wang/p/4167134.html