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)
python 自定义错误处理
原文:https://www.cnblogs.com/zjj1990/p/12924649.html