我在印象python字符串格式使用.format()将正确使用属性,而我得到一个字符串格式的对象的默认行为:
>>> def get(): return "Blah"
>>> a = property(get)
>>> "{a}!".format(a=a)
'<property object at 0x221df18>!'
Run Code Online (Sandbox Code Playgroud)
这是预期的行为,如果是的话,什么是实现属性的特殊行为的好方法(例如,上面的测试将返回"Blah!"而不是)?