#自定义异常 需要继承Exception class MyException(Exception): def __init__(self, *args): self.args = args #raise MyException('爆出异常吧哈哈')
#最简单的自定义异常 class FError(Exception): pass try: raise FError("自定义异常") except FError as e: print(e)