如何在编译期间反转Flag_to_Marker
:
class FLAG(IntEnum):
DEFAULT_ZERO = 0b0
L1 = 0b01
L2 = 0b10
RSU = 0b100
ESCALATED_COMMENTS = 0b1000
Flag_to_Marker = {L1: 'is_l1', L2: 'is_l2', RSU: 'is_rsu'}
Marker_to_Flag = {v: k for k, v in Flag_to_Marker.items()}
def marker(self, flag):
return self.Flag_to_Marker[flag]
def flag(self, marker):
return self.Marker_to_Flag[marker]
但是当我尝试构建Marker_to_Flag
:int() argument must be a string, a bytes-like object or a number, not 'dict'
时,我遇到以下异常。如何解决?
我希望Marker_to_Flag = {'is_l1': L1, 'is_l2': L2, 'is_rsu': RSU}
答案 0 :(得分:-2)
Marker_to_Flag = {v: k for k, v in Flag_to_Marker.items()}
答案 1 :(得分:-2)