迭代
列舉是可迭代的:
class Color(Enum):
red = 1
green = 2
blue = 3
[c for c in Color] # [<Color.red: 1>, <Color.green: 2>, <Color.blue: 3>]
列舉是可迭代的:
class Color(Enum):
red = 1
green = 2
blue = 3
[c for c in Color] # [<Color.red: 1>, <Color.green: 2>, <Color.blue: 3>]