class Animal(): def __init__(self, name, age, location): self.__name = name self.__age = age self.location = location def get_name(self): return self.__name def get_age(self): return self.__age def get_location(self): return self.location dog = Animal('yiky', 3, 'Cario') print(dog.get_name) print(dog.get_age) print(dog.get_location)
print(dog.get_name())
print(dog.get_age())
print(dog.get_location())
call method 的时候加个(), 例如dog.get_name()