我正在尝试使用此函数自动枚举多个常量,并在最后一行给我一个错误:
“ Enum”类没有“ POWER”成员pylint(无成员)
代码是:
from enum import Enum
def enum(*sequential,**named):
enums = dict(zip(sequential,range(len(sequential))),**named)
return type('Enum',(),enums)
meas = enum("HARMONIC","POWER","VRMS")
print (meas.POWER) #i expected: >1 (type int)
我不理解这个问题。我想要一种解决方案或其他形式。谢谢。