python enum 枚举
2017-02-13 09:21
357 查看
http://www.cnblogs.com/codingmylife/archive/2013/05/31/3110656.html
python 3.4+
python 3.4+
from enum import Enum message_type=Enum('message_type','un_read readed deleted') print(message_type.un_read.value) print(message_type.readed.value) print(message_type.deleted.value) print(dir(message_type.readed)) # 或者 class MessageType(Enum): un_read = 1 readed = 2 deleted = 3 print(MessageType.deleted.value)
# 1 # 2 # 3 # ['__class__', '__doc__', '__module__', 'name', 'name', 'value', 'value'] # [Finished in 0.2s]
相关文章推荐
- Python 的枚举类型 enum 实现
- python入门笔记(Day7)--slots,@property,MixIn,定制(str,iter,getitem,getattr,call)枚举(Enum)元type,metaclass,ORM
- Python 的枚举类型 enum 实现
- Python: Enum枚举的实现
- Python 的枚举 Enum
- 【转载】Python: Enum枚举的实现
- python Class:面向对象高级编程 Enum(枚举)、@unique
- Python: Enum枚举的实现
- 浅谈Python 的枚举 Enum
- python学习笔记:利用__getattr__属性实现枚举Enum
- python3学习笔记:枚举enum
- Python基础-枚举-Enum
- Python: Enum枚举的实现
- Python: Enum枚举的实现
- 【python】Python: Enum枚举的实现
- C#编程:枚举(enum)与结构(struct)的定义和使用方法
- enum枚举
- 利用反射遍历Enum,并显示在ComboBox上,根据枚举的值,选中在comboBox中指定的项
- C#的Enum——枚举
- 关于枚举enum的tostring方法不能重写的一种替代方案