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-18
目录

枚举类

# 枚举类

# 简单使用

from enum import Enum


class Weekday(Enum):
    MONDAY = 1
    TUESDAY = 2
    WEDNESDAY = 3
    THURSDAY = 4
    FRIDAY = 5
    SATURDAY = 6
    SUNDAY = 7


## The special attribute __members__ is a read-only ordered mapping of names to members.
## It includes all names defined in the enumeration, including the aliases:
for name, member in Weekday.__members__.items():
    print(name, member, member.value)
  1. 枚举类的__members__是一个只读的字典

# @unique


from enum import Enum, unique
@unique
class Mistake(Enum):
    ONE = 1
    TWO = 2
    ## 不允许同样的key
    THREE = 3
    FOUR = 3

多重继承
flask 入门

← 多重继承 flask 入门→

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