1 Star 0 Fork 3

tonyklose1984 / LearningPython

forked from celaraze / learning-python 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
26.多重继承.py 455 Bytes
一键复制 编辑 原始数据 按行查看 历史
Famio 提交于 2020-01-01 16:45 . 增加多重继承
# 类可以多重继承,Dog继承自Animal,Ted继承自Dog
# 定义叫声的类
class Barkable(object):
def bark(self):
print('狗在叫')
class Meowable(object):
def meow(self):
print('猫在叫')
class Animal(object):
pass
class Dog(Animal, Barkable):
pass
class Ted(Dog):
pass
class Cat(Animal, Meowable):
pass
class Bos(Cat):
pass
class Huskey(Dog):
pass
a = Huskey()
print(a.bark())
Python
1
https://gitee.com/tonyklose1984/LearningPython.git
git@gitee.com:tonyklose1984/LearningPython.git
tonyklose1984
LearningPython
LearningPython
master

搜索帮助