61-python-单继承( super )
# super 在类内部使用,可以省略self 关键字
# super 在外部调用,可以直接找到父类中的方法
class Animal: def __init__(self,name,age,sex): self.name = name self.age = age self.sex = sex def eat(self): print('Animal eat') class Person(Animal): def __init__(self,name,age,sex,eye): super().__init__(name,age,sex) self.eye = eye def eat(self): print('person eat') p = Person('q',11,1,2) p.eat() # 打印结果:person eat super(Person,p).eat() # 打印结果:Animal eat