Pyhton 自定义抛出异常
作者:互联网
class ShowError(Exception): def __init__(self, message): self.message = message def __str__(self): return self.message def A(): raise ShowError("666") try: A() except Exception as e: msg = e.message if e.__class__ == ShowError else e print(msg)
标签:__,Exception,ShowError,自定义,抛出,self,Pyhton,message,def 来源: https://www.cnblogs.com/shangwei/p/16135933.html