#狗 吃 喝 拉撒 游泳#鸟 吃 喝 拉撒 下单# class Animal:# def __init__(self):# print("执行Animal__init__")# self.func()# def eat(self):# print("%s eating"%self.name)# def drink(self):# print("%s drinking"%self.name)# def func(self):# print("Animal.func")# class Dog(Animal):# def guard(self):# print("guarding")# def func(self):# print(Dog.func)# dog=Dog()# class A:# pass# class B:# pass# class A_son(A,B):# pass# class AB_son(A):# pass# print(A.__bases__)# print(B.__bases__)# print(AB_son.__bases__)# print(A_son.__bases__)# class Animal:# def __init__(self, name ,hp ,aggr):# self .name=name# self.blood =hp# self.aggr=aggr# class Dog(Animal):# def bite(self,person):# person.hp-=self.aggr## class Person(Animal):# pass# jin=Dog("金",200,500)# print(jin.name)#单继承superclass Animal: def __init__(self, name ,hp ,aggr): self .name=name self.blood =hp self.aggr=aggr def eat(self): print("吃药回血")class Dog(Animal): def __init__(self, name ,hp ,aggr,kind): super().__init__( name ,hp ,aggr)#super只在新式类中有,python3中所有的类都是新式类 self.kind=kind def bite(self,person): person.hp-=self.aggr def eat(self): print("你今天真好看")class Person(Animal): passjin=Dog("金老板",200,500,"teedy")print(jin.name)jin.eat()super(Dog,jin).eat()#传一个类,传一个对象,不仅可以在类的内部使用,也可以在类的外部使用,如果在外部的话,需要传入类和对象
来源:https://www.cnblogs.com/648071634com/p/11852404.html