經過前面網友的提醒,我之前把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
==========================