我有这段代码:
class FileType(Enum):
BASIC = 0
BASIC_CORRUPTED = 1
BASIC_SHITTY_END = 2
MIMIKATZ = 3
HASHCAT = 4
def __eq__(self, v):
"""
Override == in order to make `FileType.BASIC == 0` equals to True, etc.
"""
return self.value == v if isinstance(v, int) else self.value == v.value
我想知道如果要执行此操作,应该添加什么:random_array[FileType.MIMIKATZ]
。目前,Python3告诉我:TypeError: list indices must be integers or slices, not FileType
random_array[FileType.MIMIKATZ.value]
。 - phoenix