나는 어디에서나 연구했지만 동일한 개념을 발견했지만 오류에 대한 답을 찾지 못하는 것 같습니다.언 바운드 오류 파이썬 클래스
내 계정 정보가 스택에서 잊어 버렸기 때문에 이전에 게시하지 못했지만이 초급 오류로 인해 매우 불만을 느꼈습니다.
class Person(object):
def __init__(self, name, phone):
self.name = name
self.phone = phone
class Employee(Person):
total_salary = 0
@staticmethod
def total_salary(self, salary):
return total_salary
def __init__(self, name, phone, salary):
self.name = name
self.phone = phone
self.salary = salary
class Student(Person):
def __init__(self, name, phone, gpa):
self.gpa = gpa
self.name = name
self.phone = phone
def __str__(self):
reply = ""
reply = "Person " + self.name + " has phone " + self.phone + "\n" + " and is a Student with gpa " + str(self.gpa)
return reply
class Professor(Employee):
def __init__(self, name, phone, salary, clas_teach):
self.clas_teach = clas_teach
self.name = name
self.phone = phone
self.salary = salary
def __str__(self):
reply = ""
reply = "Person " + self.name + " has phone " + self.phone + "\n" + " and is an Employee with salary " + str(self.salary) + "\n"
reply += " and is a Professor assigned to class " + self.clas_teach
return reply
class Staff(Employee):
def __init__(self, name, phone, salary, position):
self.position = position
self.name = name
self.phone = phone
self.salary = salary
def __str__(self):
reply = ""
reply = "Person " + self.name + " has phone " + self.phone + "\n" + " and is an Employee with salary " + str(self.salary) + "\n"
reply += " and is Staff with title " + self.position
return reply
# Create a list of people
People = [ Student("Sandy", "326-8324", 3.65), Student("Jordan", "632-7434", 3.1), \
Professor("Leslie", "985-2363", 50000.00, "Info 501"), \
Staff("Alex", "743-4638", 25000.00, "Editor") ]
# display information about our people
print "These are the people in the university:"
for person in People:
print person
# display the total salaries of all our employees and average GPA
# of all of our students
print
print "Our total university payroll budget is: " + str(Employee.total_salary)
print "Our average student GPA is: " + str(Student.mean_gpa())
오류가 <0x02682670에서 기능 total_salary이> 지금를 사용하여 더 명확하게 할 수 있지만, @staticmethod없이 나에게 준 <언 바운드 방법을 Employee.total_salary> –
당신을 결코 total_salaries 메소드에서 급여를 합하면 사용되지 않는 두 개의 매개 변수를 전달하고'total_salary'는 반환되지 않고 클래스 속성도 사용되지 않습니다. 너 뭐하려고? 이 문제를 어떻게 해결하고 싶습니까? –
People에 직원의 급여를 추가하려고하지만 직원을 추가 할 때 급여가 추가되는지 확인하려고합니다. –