我最近从一个stackoverflow question中看到了这段代码:
@unique
class NetlistKind(IntEnum):
Unknown = 0
LatticeNetlist = 1
QuartusNetlist = 2
XSTNetlist = 4
CoreGenNetlist = 8
All = 15
def __contains__(self, item):
return (self.value & item.value) == item.value
@unique
修饰符做什么,它在这个代码片段中的用途是什么?在
来自documentation(谢谢@HFBrowning):
基本上,如果存在任何重复的枚举值,则会引发错误。在
这个代码
产生此错误:
^{pr2}$相关问题 更多 >
编程相关推荐