适用于Employee
和calculate_wage
,但在我尝试创建PartTimeEmployee
的实例并调用calculate_wage
PartTimeEmployee
方法时会返回错误}的父类。
class Employee(object):
"""Models real-life employees!"""
def __init__(self, employee_name):
self.employee_name = employee_name
def calculate_wage(self, hours):
self.hours = hours
return hours * 20.00
class PartTimeEmployee(Employee):
def __init__(self, employee_name):
self.employee_name = employee_name
def calculate_wage(self, hours):
self.hours = hours
return hours * 12.00
def full_time_wage(self, hours):
return super(PartTimeEmployee, self).calculate_wage(self, hours)
milton = PartTimeEmployee("Milton")
print (milton.full_time_wage(10))
答案 0 :(得分:5)
return super(PartTimeEmployee, self).calculate_wage(self, hours)
不正确,应该是
return super(PartTimeEmployee, self).calculate_wage(hours)
下一次:同时发布您看到的错误消息。