大家好,又见面了,我是全栈君。
1 class DerivedClassName(Base1,Base2,Base3): 2 <statement-1> 3 . 4 . 5 . 6 <statement-N>
1 #! /usr/bin/python 2 #-*-coding:UTF-8-*- 3 #class_多重继承 4 5 class Animal(object): 6 pass 7 8 #大类: 9 class Mammal(Animal): 10 pass 11 12 class Bird(Animal): 13 pass 14 15 #各种动物: 16 class Dog(Mammal): 17 pass 18 19 class Bat(Mammal): 20 pass 21 22 class Parrot(Mammal): 23 pass 24 25 class Ostrich(Mammal): 26 pass
1 class Runnable(object): 2 def run(self): 3 print('Is Running...') 4 5 class Flyable(object): 6 def fly(self): 7 print('Is Flying...')
1 class Dog(Mammal,Runnable): 2 pass
1 class Bat(Manmmal,Flyable): 2 pass
1 dog=Dog 2 dog.run
1 D:\Pythonworkspace>python class_多重继承.py 2 Is Running...
转载于:https://www.cnblogs.com/DLHe/p/8027402.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/107842.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...