class Persion():
#@property一般写在get方法上面
@property
def name(self):
return self._name
@name.setter
def name(self,name):
self._name=name+',hello'
#像操作属性一样调用方法
p = Persion();
p.name='Tom'
print(p.name)
C:\Users\Administrator.000\AppData\Local\Programs\Python\Python36\python.exe E:/python/15.@property关键字.py
Tom,hello
Process finished with exit code 0