我写了一个程序,其中有一段是这样的:
class Detector(Enum): BBO = "BBO" DECIGO = "DECIGO" @property def ell_max(self) -> int: ell_max = { Detector.BBO: 30, Detector.DECIGO: 30, } return ell_max[self] 我现在需要在一个循环中改变 ell_max 的值,也就是不设置为 30 了,而是设置成其他值。我尝试过定义一个 def set_ell_max(self, ell_max) 但最终失败了。我的失败品如下:
class Detector(Enum): BBO = "BBO" DECIGO = "DECIGO" _ell_max_values = { DECIGO: 30, BBO: 30, } @property def ell_max(self) -> int: return self._ell_max_values[self] def set_ell_max(self, value: int): self._ell_max_values[self] = value 这种情况下,当我使用 Detector.BBO.ell_max 的时候,会提示 ```TypeError: 'Detector' object is not subscriptable
请问各位大哥,我该怎么处理呀? 