lhl
首页
python
leetcode
产品思想
软件测试
博客 (opens new window)
github (opens new window)
首页
python
leetcode
产品思想
软件测试
博客 (opens new window)
github (opens new window)
  • python

    • Python 基础

    • Python 数据库

    • 面向对象

      • 面向对象基础
      • 继承
      • slot
      • @property
      • 多重继承
        • 多重继承
      • 枚举类
    • Python Web

    • Python 进阶

  • leetcode

  • 软件测试

  • Git

  • linux

  • 产品

  • MySql

  • docker

  • python
  • 面向对象
2023-07-16
目录

多重继承

# 多重继承

# 简单使用

## 动物分为哺乳类和鸟类
## 可以按照能飞能跑分类,分成能飞派和能跑派
class Animal(object):
    pass


## 哺乳类 和 鸟类
class Mammal(Animal):
    pass


class Bird(Animal):
    pass


## 能飞,能跑类
class Flyable(object):
    def flying(self):
        print('flying')


class Runnable(object):
    def running(self):
        print('running')


## Dog 类
class Dog(Mammal, Runnable):
    pass


## Parrot 类
class Parrot(Bird, Flyable):
    pass

# MixIn

可以理解为 Java 中 类和接口的关系

MixIn (opens new window)

@property
枚举类

← @property 枚举类→

最近更新
01
lhl learn notes
02
filter
06-09
03
decorator
06-09
更多文章>
Theme by Vdoing
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式