[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Lovepython015/Python/master/Article/PythonBasis/python11/1.md [Back]  [Original]

#  #



```python
JAN = 1
FEB = 2
MAR = 3
...
NOV = 11
DEC = 12
```

 `int` 



 class  class 

 Python  Enum 

```python
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

from enum import Enum

Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))

# 
for name, member in Month.__members__.items():
    print(name, '---------', member, '----------', member.value)

# 
print('\n', Month.Jan)

```




![](http://twowaterimage.oss-cn-beijing.aliyuncs.com/2019-10-14-Python3%20%E6%9E%9A%E4%B8%BE%E7%B1%BB%E5%9E%8B%E7%9A%84%E4%BD%BF%E7%94%A8.png)

 `Enum` 

 Month  Month  tuple  `__members__` 

  `member.value`  `int`  1 

** Enum Singleton**



Web Proxy Viewer  |  New URL  |  Original Page