0

它适用于Employeeand 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))
4

1 回答 1

5
return super(PartTimeEmployee, self).calculate_wage(self, hours)

不正确,应该是

return super(PartTimeEmployee, self).calculate_wage(hours)

下一次:同时发布您看到的错误消息。

于 2013-10-05T10:44:20.693 回答