📜  覆盖类的 python 打印 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:36.184000             🧑  作者: Mango

代码示例1
>>> class Test:
...     def __repr__(self):
...         return "Test()"
...     def __str__(self):
...         return "member of Test"
... 
>>> t = Test()
>>> t
Test()
>>> print(t)
member of Test