项目结构:
Dog、Cat模块引用Animal模块
Animal模块代码:
# -*- coding:UTF-8 -*- # 定义一个动物类 class Animal(object): def run(self): print('动物类的run方法....')
Dog模块代码:
# -*- coding:UTF-8 -*- from extends_demo.Animal import Animal class Dog(Animal): pass
Cat模块代码:
# -*- coding:UTF-8 -*- from extends_demo.Animal import Animal class Cat(Animal): pass