python自定义异常
class ShortInputException(Exception):
def __init__(self, msg):
self.msg = msg
def __str__(self):
return str(self.msg)
try:
print('zz')
raise ShortInputException('短了。。。')
except Exception as e:
print(e)
代码如上所示:

浙公网安备 33010602011771号