首页 > 代码库 > Python基础课:不一样的多继承

Python基础课:不一样的多继承

class Animal:
    pass


class Mammal(Animal):#哺乳类
    pass


class Bird(Animal):#鸟类
    pass



class Dog(Mammal): #狗类
    pass


class Parrort(Bird): #鹦鹉类
    pass



class Runnable:  #跑类
    def run(self):
        print(running...)


class Flyable:  #分类
    def fly(self):
        print(flying...)


#多继承开始了,注意高能预警
class Dog(Mammal, Runnable):
    pass

class Parrot(Bird, Flyable):
    pass

 

Python基础课:不一样的多继承