经过前面网友的提醒,我之前把class的格式看得太死,
该把它想成跟一般函式一样,里面的def也可以在 class中使用
=========================
class A(object):
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = value
==========================
跟下面是同等的。
==========================
class A(object):
def x(self):
return self._x
x = property(x)
@x.setter
def x(self, value):
self._x = value
==========================