class ShortInputError(Exception):# 自定义异常def __init__(self, length, atleast):self.length = lengthself.atleast = atleasttry:text = input('请输入密码:\n')if len(text) < 3:raise ShortInputError(len(text), 3)except ShortInputError as result:print(f"输入的长度是{result.length},长度至少应该是{result.atleast}")else:print("成功")
