property 和 setter 装饰器
class A:
def __init__(self):
self._name = 'aaa'
@property
def name1(self):
return self._name
@name1.setter
def name(self,n):
self._name = n
a = A()
a.name = 'ccc'
a.name
class A:
def __init__(self):
self._name = 'aaa'
@property
def name1(self):
return self._name
@name1.setter
def name(self,n):
self._name = n
a = A()
a.name = 'ccc'
a.name