python 类方法__str__() python 类方法__str__()用于对该类的说明,可以直接通过print方式打印出来。 class ABC: def __str__(self): return "abc的说明..." # 创建了一个对象 abc = ABC() print(abc) 注意,__str__()必须返回一个字符串,而且不允许有输入参数。