python __str__ 与 __repr__区别
>>> class test(): def __init__(self): pass def __repr__(self): return '1sdf' >>> t = test() >>> t #不用print 直接打印出重构的值,面向程序,在程序中传递 1sdf >>> class test(Exception): def __init__(self): pass def __str__(self): #p return '1sdf' >>> print(test()) #调用print打印重构值, 面向用户交互,首先调用__str__的值 1sdf >>> test() #打印输出为函数