property装饰器
property装饰器示例
class Person:
def __init__(self,name):
self.__name=name
def getname(self):
return self.__name
def setname(self,value)
self.__name=value
def delname(self):
def self.__name
name=property(getname,setname,delname,"i am the name property")
if __name__=="__main__":
p=Person('11111')
print(p.name)
p.name="22222"
print(p.name)