property干嘛的

>>> import datetime
>>> class c():
    @property
    def noww(self):
        return datetime.datetime.now()

    
>>> c.noww
<property object at 0x00000000031DE908>
>>> x=c()
>>> x.noww
datetime.datetime(2014, 1, 27, 13, 17, 14, 725610)
>>> x.noww
datetime.datetime(2014, 1, 27, 13, 17, 27, 8740)
>>> x.noww()
Traceback (most recent call last):
  File "<pyshell#50>", line 1, in <module>
    x.noww()
TypeError: 'datetime.datetime' object is not callable

看来应该是免得每次都要敲对括号

原文地址:https://www.cnblogs.com/xiangnan/p/3534795.html