小编Owe*_*orn的帖子

多继承python问题

所以我目前正在为我的一个类学习 python 的继承,并且作业让我们对 ScientificSwimmer 类使用多重继承。当您尝试在不创建所述类的对象的情况下运行代码时,程序将运行。但是,在创建该类的对象时,出现以下错误。任何建议或解决方案将不胜感激。(在帖子中添加行号)

#creation of Human class
class Human:  

    def __init__(self, name, age): #talks a name and balance and creates a instance of class
        self.age = age
        self.name = name
    
    def hobby(self):#Hobby method
        print("Likes to watch Netflix")
        
    def info(self):#info method
        print(self.name, " is ", self.age, " years old.")
        

#creation of the Scientist class
class Scienctist(Human):
    
    def __init__(self, name, age, lab):
        super().__init__(name, age)
        self.lab = lab
        
    def hobby(self):
        print("Likes watching Bill Nye the science guy.")
        
    def labName(self):
        print("Works at …
Run Code Online (Sandbox Code Playgroud)

python class multiple-inheritance

6
推荐指数
1
解决办法
162
查看次数

标签 统计

class ×1

multiple-inheritance ×1

python ×1