【发布时间】:2018-04-25 15:22:07
【问题描述】:
class Employee(object):
def __init__(self,ename,salary,dateOfJoining):
self.ename=ename
self.salary=salary
self.dateOfJoining=dateOfJoining
def output(self):
print("Ename: ",self.ename,"\nSalary: ",self.salary,"\nDate Of
Joining: ",self.dateOfJoining)
class Qualification(object):
def __init__(self,university,degree,passingYear):
self.university=university
self.degree=degree
self.passingYear=passingYear
def qoutput(self):
print("Passed out fom University:",self.university,"\nDegree:",self.degree,"\Passout year: ",self.passingYear)
class Scientist(Employee,Qualification):
def __int__(self,ename,salary,dateOfJoining,university,degree,passingYear):
Employee.__init__(self,ename,salary,dateOfJoining)
Qualification.__init__(self,university,degree,passingYear)
def soutput(self):
Employee.output()
Qualification.output()
a=Scientist('Ayush',20000,'21-04-2010','MIT','B.Tech','31-3-2008')
a.soutput()
我无法找到问题的解决方案,也无法理解为什么会发生此 TpyeError。我是蟒蛇的新手。谢谢
【问题讨论】:
-
错误发生在哪个类?你能给我们完整的异常跟踪吗?
-
科学家班
-
发布显示错误发生行的python回溯。
-
@tdelaney 在这里你可以追溯(最近一次调用最后一次):文件“C:/Python34/84.py”,第 22 行,在
a=Scientist('Ayush',20000,' 21-04-2010','MIT','B.Tech','31-3-2008') TypeError: __init__() 接受 4 个位置参数,但给出了 7 个 -
您在
__init__中有错字。你写了__int__。它使用父类的dunder init
标签: python multiple-inheritance