class clientError(Exception): def init(self,information): super().init(self) self.error=information def str(self): return self.error 测试异常 from 自定义异常 import clientError if name=='main': try: raise clientError('客户端异常') except clientError as e: print(e)测试