关于python:TypeError:__ init __()需要3个位置参数,但是给出了4个

TypeError: __init__() takes 3 positional arguments but 4 were given

以下是我的课程代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Employee:
    def __init__(self, name, gender):
        self.name = name
        self.gender = gender

class Salary:
    def jump(self, name, salary):
        print(self.name, self.salary)


class Male(Salary, Employee):
    def __init__(self, name, gender, occupation):
        super(Male, self).__init__(name, gender, occupation)
        self.occupation = occupation

# Separate from all classes (list of instantiated objects)
employee1 = Male("Jim","male","technician")
print(Male.name)

当我在创建完所有类后使用代码的最后两行时,"typeerror:init()接受3个位置参数,但给出了4个"引用super(male,self)时出错。雇员1=男性(…)线。


在宠物下面你有:

1
2
3
def __init__(self, name, color):
    self.name = name
    self.color = color

在狗下面你有:

1
2
def __init__(self, name, color, owner):
    super(Dog, self).__init__(name, color, owner)

在dog下有一个额外的所有者位置参数,这导致了这个错误。另一方面,我认为,在Python 3中,EDOCX1 0也同样适用。