已采纳回答 / 柳随风
calss Anmial(object): def __init__(self,name,age): self.name = name self.age = agedog = Anmial('Tim',4)cat = Anmial('Aim',5)print(dog.name)print(dog.age)print(cat.name)print(cat.age)<...code...>
2021-01-23
已采纳回答 / 柳随风
calss Anmial(object): count = 0 def __init__(self,name,age): self.name = name self.age = age Animal.count =Animal.count + 1dog = Animal('wangwang',1)print(Animal.count)cat = Animal('mimi',3)print(Animal.count)pig ...
2021-01-23
已采纳回答 / 柳随风
calss Animal(object): def __init__(self,name,age) self.name = name self.age = age dog = Animal('Tim',4) cat = Animal('Aim',5) print(dog.name) print(dog.age) print(cat.name) print(cat.age)<...code...>
2021-01-22
最赞回答 / 半阵封涵
可以啊
class Student(Person): __slots__ = ('score',) def __init__(self, name, gender, score): super(Student, self).__init__(name, gender) self.score = score与
class Student(Per...
2021-01-21
已采纳回答 / 粗实而夜雨
给出的Animal类里面并没有具体的初始化内容,只是调用了pass函数,所以会报错,你把pass里的内容替换下,def __init__(self,name,age) 就可以了
2021-01-20