#coding:utf-8 class Person(object): def __init__(self,name, age): self._name = name self._age = age @property def name(self): return self._name @property def age(self): return self._age @name.setter def name(self, val): self._name = val if __name__ == "__main__": person = Person("Atom", 27) print person.name, person.age person.name = "shylock" print person.name, person.age
时间: 2024-11-03 05:39:57