from enum import Enum #Enum 枚举类型!!!!! Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) for name, member in Month.members.items(): #members 遍历!!! print(name, '=>', member, ',', member.value) #value属性则是自动赋给成员的int常量,默认从1开始计数。!!!! 输出是 Oct => Month.Oct , 10 Nov => Month.Nov , 11 Dec => Month.Dec , 12
龟速学习中 不学了,碎觉。