'''
class Person(object):
def __init__(self, name, age):
# self.name = name
self.__name = name # __name即私有属性,设置 _Person__name = ”yuan“
self.__age = age
@property #私有属性,功能:查看
def name(self):
return self.__name
@name.setter #私有属性,功能:修改
def name(self, new_name):
self.__name = new_name
def set_age(self, new_age):
if new_age < 200:
self.__age = new_age
raise Exception("年龄不能超过两百岁!")
def get_age(self):
print(self.__age)
p1 = Person("xi", 22)
print(p1.name) # xi
p1.name = "huchangxi"
print(p1.name) # huchangxi
print(type(p1)) #<class '__main__.Person'>
'''