定义
from enum import Enum Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
使用
print(Month(1)) # Month.Jan print(Month(1).name) # Jan. 每一个枚举类默认有一个value,从1开始.
Sign in to make a reply
阿茜茜Victoria
定义
使用