Python 作为定义类型而不是枚举成员出现的枚举类成员

Python 作为定义类型而不是枚举成员出现的枚举类成员,python,python-2.7,enums,Python,Python 2.7,Enums,我正在实现一个枚举类,但它一直显示为普通类变量。例如: from enum import Enum class test(Enum): one = 1 two = 2 thr = "three" 利用这个,我得到: >>> print type(test.one) <type 'int'> >>> print repr(test.one) 1 >>> print test.one 1 >>

我正在实现一个枚举类,但它一直显示为普通类变量。例如:

from enum import Enum

class test(Enum):
    one = 1
    two = 2
    thr = "three"
利用这个,我得到:

>>> print type(test.one)
<type 'int'>
>>> print repr(test.one)
1
>>> print test.one
1

>>> print type(test.thr)
<type 'str'>
>>> print repr(test.thr)    
'three'
>>> print test.thr
three

Python3.4中引入的枚举在下进行了后端口。您似乎不幸安装了这个完全不同的软件包。

您使用的是什么
enum
模块?它没有随Python2.7stdlib一起提供。我使用
pip安装--user enum
--安装了它。有没有办法确保这是正在使用的版本?(我在远程服务器上,所以可能发生了一些奇怪的事情)是的@kalhartt谢谢你,你这个可爱的人。将此作为一个答案,以便我可以投票并标记它?如果您对将
Enum
引入标准库背后的想法感兴趣,那么值得一读。
$ python --version
Python 2.7.3

$ python -c "import enum; print enum.__version__"
0.4.4