python 类的打印__str__

__str__一般是格式:

class A:
def __str__(self):
return "this is in str"

事实上,__str__是被print函数调用的,一般都是return一个字符串。当打印一个类的时候,那么print首先调用的就是类里面的定义的__str__