标签:python prope code sel mamicode lazy ini class loading
```python
class Human:
def __init__(self, name, age):
self.__name = name
self.__age = age
@property
def age(self):
return self.__age
@age.setter
def age(self, age):
if age > 0:
self.__age = age
else:
print(‘error‘)
h1 = Human(‘sai‘,22)
print(h1.age)
h1.age += 5
print(h1.age)
python @property和@attribute.setter理解
标签:python prope code sel mamicode lazy ini class loading
原文地址:https://www.cnblogs.com/xiaozhusai/p/14747722.html