class aTest:
def __repr__(self):
return "This is an aTest class."
a = aTest()
print (a)
class bTest:
pass
b = bTest()
print(b)
输出结果:
This is an aTest class.
<__main__.bTest object at 0x102a7f8d0>
所以,__repr__
决定了直接打印一个实例时输出的字符串。