1.1 多重继承
>>> #最大类
... class Animal(object):
... pass
...
>>> #大类
... class Mammal(Animal):
... pass
...
>>> class Bird(Animal):
... pass
...
>>> class Runnable(object):
... def run(self):
... print(‘Running...‘)
...
>>> classDog(Mammal, Runnable): --同时继承Mammal, Runnable两个父类的功能
... pass
...
>>> s = Dog()
>>> s.run()
Running...
Mixln
在设计类的继承关系时,通常,主线都是单一继承下来的;然而多重继承,为了更好的看出多重继承的关系,加上Mixln。
>>> classDog(Mammal, RunnableMixln, xxxxMixln ……):
... pass
...
时间: 2024-10-08 17:32:11