修改location值无法完成
class Animal(object):
def __init__(self, name, age, localtion):
self.__name = name
self.__age = age
self.__localtion = localtion
def get_info(self):
return 'name = {}, age = {}, localtion = {}'.format(self.__name, self.__age, self.__localtion)
def change_info(self,name,age,location):
self.__name = name
self.__age = age
self.__location = location
dog = Animal('wangwang', 1, 'GuangDong')
print(dog.get_info())
dog.change_info('wangcai',3,'Error')
print(dog.get_info())
标注为Error的为最后输出错误的地方
结果仍为“GongDong”