枚举不能在Python 2.7中迭代

shr*_*shr 4 python enums python-2.7

from enum import Enum

class Shake(Enum):
    __order__ = 'vanilla chocolate cookies mint' # only needed in 2.x
    vanilla = 7
    chocolate = 4
    cookies = 9
    mint = 3

for shake in Shake:
    print shake
Run Code Online (Sandbox Code Playgroud)

运行此代码时出错

  for shake in Shake:
TypeError: 'type' object is not iterable
Run Code Online (Sandbox Code Playgroud)

EnumPython 2.7中不支持迭代吗?如果我们创建该Enum类型的对象,它就有效.

Eth*_*man 9

Python 3.4 Enum类型的后端enum34,而不是枚举.