我在python中有以下代码:
class state:
def _init_(self):
self.x=list([])
self.possibleChests=list([])
self.visitedChests=list([])
def checkKeys(self):
print self.x
def addKey(self,x):
self.x.append(key)
current_state=state()
future_state=state()
current_state.addKey(4)
当我运行它时,我收到以下错误:
AttributeError: state instance has no attribute 'x'
为什么'x'未被识别为实例属性?
答案 0 :(得分:1)