Python Cookbook 3rd 的 1.5 章有一段代码如下:
>>> class Item:
... def __init__(self,name):
... self.name=name
... def __repr__(self):
... return 'Item({!r})'.format(self.name)
...
请问 return 语句中的 !r 是什么意思,我咋个都搜不到,谢谢!
1
wd 2019-03-03 13:25:28 +08:00 via iPhone 1
Three conversion flags are currently supported: '!s' which calls str() on the value, '!r' which calls repr() and '!a' which calls ascii().
|
2
patrickstar OP @wd thanks
|