class Person: def __init__(self, name, age=0): self._name = name self._age = age @property def name(self): return self._name @name.setter def name(self, value): self._name = value @property def age(self): return self._age @age.setter def age(self, value): self._age = value
时间: 2024-01-04 09:02:25 浏览: 176
hw_python_oop:冲刺2。
抱歉,由于排版原因,我之前的代码示例可能没有显示完整。以下是完整的代码示例:
```python
class Person:
def __init__(self, name, age=0):
self._name = name
self._age = age
@property
def name(self):
return self._name
@name.setter
def name(self, value):
self._name = value
@property
def age(self):
return self._age
@age.setter
def age(self, value):
self._age = value
```
请问还有其他问题吗?
阅读全文