项目初次提交
This commit is contained in:
27
core/enum.py
Normal file
27
core/enum.py
Normal file
@ -0,0 +1,27 @@
|
||||
#!/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())
|
Reference in New Issue
Block a user