1.枚举类声明
import enum
class Season(enum.Enum):
SPRING = '春'
SUMMER = '夏'
AUTUMN = '秋'
WINTER = '东'
2.创建枚举类的对象
season = Season.SPRING
3.访问器属性
#name属性
print(season.name) # SPRING
#value属性
print(season.value) # 春
原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/python/pythonlang/35982.html