enum

常量配置

from enum import Enum

class CustomType(Enum):
    SOURCE = '网站到访'
    ALLOCATION = '一部'
    PROVINCE = '北京'
    CITY = '北京'

print(CustomType.SOURCE.name)    # 'SOURCE'
print(CustomType.SOURCE.value)   # '网站到访'

Last updated