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)
代码如上所示: