实例中无法传递类参数,会报错提示Animal类中不需要参数,但是后面调用的方法需要传递3个参数
class Animal(object):
def __init(self,name,age,location):
self.__name = name
self.__age = age
self.__location = location
def set_name(self,name):
self._name = name
def get_name(self):
return self._name
def set_age(self,age):
self._age= age
def get_age(self):
return self._age
def set_location(self,location):
self._location = location
def get_location(self):
return self._location
dog= Animal()
print(dog.__name)
把你的代码贴出来看一下