自定义异常的两种方式
try:
a=2;b=1
if a>b:
raise Exception("dayu")
except Exception as ff:
print (ff)
————————————————————————————
class ownerException(Exception):
def __init__(self,message):
self.message=message
try:
a=2;b=1
if a>b:
raise ownerException("dayu!!!")
except ownerException as gg:
print (gg.message)

浙公网安备 33010602011771号