麻烦大神看一下,为什么代码运行后显示Skill不存在?(已解决)
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
class Student(Person):
def __init__(self, name, age, grade):
super(Student, self).__init__(name, age)
self.grade = grade
class Teacher(Person):
def __init__(self, name, age, subject):
super(Teacher,self).__init__(name,age)
self.subject = subject
class Skill(object):
def __init__(self,skill):
self.skill = skill
class Basketball(Skill):
def __init__(self,skill, level):
super(Basketball, self).__init__(skill)
self.level = level
class Football(Skill):
def __init__(self,skill,level):
super(Football, self).__init__(skill)
self.level=level
class BK(Student,Basketball):
def __init__(self,name,age,grade,skill,level,practise_time):
Student.__init__(self,name, age, grade)
Basketball.__init__(self, skill, level)# super(BK,self).__init__(name,age,grade,skill,level)(原来是这样写的,外部调用不了第二父类的属性)
BK.practise_time=practise_time
class FT(Teacher,Football):
def __init__(self,name,age,subject,skill,level,practise_time):
Teacher.__init__(self,name,age,subject)
Football.__init__(self,skill,level)
# super(FT,self).__init__(name,age,subject,skill,level)
FT.practise_time = practise_time
a = BK('LiMing', 13, 13,'Basketball', 3, 6)
b = FT('LiLei', 40, 'Math', 'Football',6,20)
print(a.age)
print(b.skill)