自定义一个异常

class Myexception(Exception):
    def __init__(self,message):
        self.message=message
    def __str__(self):
        return self.message
try:
    raise Myexception("我错了")
except Myexception as e:
    print(e)

猜你喜欢

转载自www.cnblogs.com/yangzhen-ahujhc/p/12304557.html