Python 最小枚举 (enum.Enum) 示例

python-minimal-enum-enum-enum-example.py
from enum import Enum

class Shape(Enum):
    Circle = 0
    Square = 1
    Hexagon = 2

# 使用示例
print(Shape.Square) # 打印 Shape.Square

基于官方 enum 包文档


Check out similar posts by category: Python