简单的自定义异常处理
class CustomizeError(BaseException): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg try: raise CustomizeError('错误类型') except CustomizeError as e: print(e)
class CustomizeError(BaseException): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg try: raise CustomizeError('错误类型') except CustomizeError as e: print(e)