【发布时间】:2011-04-03 06:37:05
【问题描述】:
这个交互式 python 控制台 sn-p 会告诉一切:
>>> class Test:
... def __str__(self):
... return 'asd'
...
>>> t = Test()
>>> print(t)
asd
>>> l = [Test(), Test(), Test()]
>>> print(l)
[__main__.Test instance at 0x00CBC1E8, __main__.Test instance at 0x00CBC260,
__main__.Test instance at 0x00CBC238]
基本上我想在打印列表时打印三个asd 字符串。我也尝试过pprint,但结果相同。
【问题讨论】:
标签: python list object printing string