Python枚举的常见做法是什么? [英] What's the common practice for enums in Python?
本文介绍了Python枚举的常见做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Python枚举的常见做法是什么?即如何在Python中复制它们?
What's the common practice for enums in Python? I.e. how are they replicated in Python?
public enum Materials
{
Shaded,
Shiny,
Transparent,
Matte
}
推荐答案
class Materials:
Shaded, Shiny, Transparent, Matte = range(4)
>>> print Materials.Matte
3
这篇关于Python枚举的常见做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文