Numpy.load:导致RuntimeError

时间:2017-12-09 13:33:20

标签: python numpy pygame pytmx

尝试加载pytmx.objects变量,我可以做Numpy.save就好了,但是加载导致它进入无限循环的返回。任何人都知道为什么以及如何解决它?我正在使用numpy save只是因为它无法定期腌制。如果有人知道另一种保存变量的方法,我也会对这些建议持开放态度。 (杰森也没有工作。)

Traceback (most recent call last):
  File "main.py", line 375, in <module>
    game.gameLoop()
  File "main.py", line 242, in gameLoop
    save = np.load(savefile)
  File "C:\Users\tayle_000\python game\Cyber Warfare\py\lib\site-packages\numpy\lib\npyio.py", line 419, in load
    pickle_kwargs=pickle_kwargs)
  File "C:\Users\tayle_000\python game\Cyber Warfare\py\lib\site-packages\numpy\lib\format.py", line 640, in read_array
    array = pickle.load(fp, **pickle_kwargs)
  File "C:\Users\tayle_000\python game\Cyber Warfare\py\lib\site-packages\pytmx\pytmx.py", line 214, in __getattr__
    return self.properties[item]
(A Ton More)
RuntimeError: maximum recursion depth exceeded

这是我的代码:

def gameLoop(self):
gameExit=False
#print gameMap.layers
if os.path.isfile(os.path.join('saves','game.save')):
  savefile = open(os.path.join('saves','game.save'), 'rb')
  save = np.load(savefile)
  savefile.close()
  save=save.tolist()
  if save['version']==self.version:
    self.worlds['base'].tmx=save['base']
    self.worlds['servers'].tmx=save['servers']
    self.worlds['res'].tmx=save['res']
    self.gain=save['gain']
  else:
    print "Save file version is incompatible.  Starting new game."
else:
  print "No save file found.  Starting new game."
while not gameExit:
  #############Events
  for event in pygame.event.get():
    if event.type==pygame.QUIT:
      save={'version':self.version, 'base':self.worlds['base'].tmx, 'servers':self.worlds['servers'].tmx, 'res':self.worlds['res'].tmx, 'gain':self.gain}
      savefile = open(os.path.join('saves','game.save'), 'wb')
      np.save(savefile, save)
      savefile.close()
      gameExit=True
      return False

0 个答案:

没有答案