28 lines
663 B
Python
28 lines
663 B
Python
|
#!/usr/bin/python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
# @version : 1.0
|
||
|
# @Create Time : 2023/02/12 22:18
|
||
|
# @File : enum.py
|
||
|
# @IDE : PyCharm
|
||
|
# @desc : 增加枚举类方法
|
||
|
|
||
|
from enum import Enum
|
||
|
|
||
|
|
||
|
class SuperEnum(Enum):
|
||
|
|
||
|
@classmethod
|
||
|
def to_dict(cls):
|
||
|
"""Returns a dictionary representation of the enum."""
|
||
|
return {e.name: e.value for e in cls}
|
||
|
|
||
|
@classmethod
|
||
|
def keys(cls):
|
||
|
"""Returns a list of all the enum keys."""
|
||
|
return cls._member_names_
|
||
|
|
||
|
@classmethod
|
||
|
def values(cls):
|
||
|
"""Returns a list of all the enum values."""
|
||
|
return list(cls._value2member_map_.keys())
|