把一个方法伪装成一个属性
class A:
def __init__(self,name,age):
self.name=name
self.__age=age
@property
def age(self):
print(self.__age)
@age.setter
def age(self,reage):
self.__age=reage
@age.deleter
def age(self):
del self.__age
a=A('dahuang',18)
print(a.__dict__)
a.age=20
a.age
del a.age
print(a.__dict__)