Frivolo
2021-06-15 17:45
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()
Python3 进阶教程(新版)
41910 学习 · 236 问题
相似问题