在python中枚举是一种类(Enum)

  1. 枚举类中不能存在相同的标签名
  2. 枚举是可迭代的

例:

from enum import Enum
class Vip(Enum):
    MONDAY = 0
    TUESDAY = 1
    WEDNESDAY = 2
    THURSDAY = 3
    FRIDAY = 4
    SATURDAY = 5
    SUNDAY = 6

功能1:获取枚举类中定义的枚举成员

Vip.MONDAY
Vip['MONDAY']
Vip(0)

功能2:获取枚举成员包含标签名与对应的值

Vip.MONDAY.name
Vip.MONDAY.value