AttributeError: can't set attribute in python

前端 未结 3 1259
旧时难觅i
旧时难觅i 2020-12-15 02:35

Here is my code

N = namedtuple(\"N\", [\'ind\', \'set\', \'v\'])
def solve()
    items=[]
    stack=[]
    R = set(range(0,8))
    for i in range(0,8):
              


        
3条回答
  •  庸人自扰
    2020-12-15 02:43

    For those searching this error, another thing that can trigger AtributeError: can't set attribute is if you try to set a decorated @property that has no setter method. Not the problem in the OP's question, but I'm putting it here to help any searching for the error message directly. (if you don't like it, go edit the question's title :)

    class Test:
        def __init__(self):
            self._attr = "original value"
            # This will trigger an error...
            self.attr = "new value"
        @property
        def attr(self):
            return self._attr
    
    Test()
    

提交回复
热议问题