关于python中定义异常过程中出现的的小问题

使用的是pycharm,python版本3.9,想要定义一个输入长度不足的异常。

代码如下:

class ShortInputException(Exception):
    def _int_(self,length,atleast):
        self.length=length
        self.atleast=atleast
try:
    text=input('please enter the password:')
    if len(text)<3:
        raise ShortInputException(len(text),3)
except EOFError:
    print('you have entered an end sign')
except ShortInputException as result:
    print('ShortInputException:you entered:%d,the len must be at least:%d'%(result.length,result.atleast))
else:
    print('no error happened')

错误如下:

please enter the password:1
Traceback (most recent call last):
  File "/home/hcc/PycharmProjects/pythonProject/test2.py", line 8, in <module>
    raise ShortInputException(len(text),3)
__main__.ShortInputException: (1, 3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hcc/PycharmProjects/pythonProject/test2.py", line 12, in <module>
    print('ShortInputException:you entered:%d,the len must be at least:%d'%(result.length,result.atleast))
AttributeError: 'ShortInputException' object has no attribute 'length'

你debug调试发现,result是以元组格式表示的,如图

如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢