mirror of https://github.com/TwoWater/Python
14 lines
364 B
Python
14 lines
364 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
from enum import Enum
|
|
|
|
Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
|
|
|
|
# 遍历枚举类型
|
|
for name, member in Month.__members__.items():
|
|
print(name, '---------', member, '----------', member.value)
|
|
|
|
# 直接引用一个常量
|
|
print('\n', Month.Jan)
|