EOFError:加载时跑出输入

问题描述

我正在尝试创建一个需要保存和加载功能的基于文本的游戏。我已经创建了函数,但是在尝试加载时出现此错误

进口泡菜 导入操作系统 导入os.path 从操作系统导入系统,名称 #角色类 班级人物:

def __init__(self,fname,lname,trust,anger):
    self.fname = fname
    self.lname = lname
    self.trust = trust
    self.anger = anger

Silez = character("Silez","",0)

Xenon = character("Xenon",0)

Neko = character("Neko",0)

Aroma = character("Aroma",0)

Castellano = character("Castellano",0)

One = character("One",0)

Six = character("Six",0)

Rin = character("Rin",0)
#- End of: Character initialisation -

#Game variables
mode = ""
current_chapter = 0
prev_chapter = current_chapter - 1
load_and_save = [Silez,Xenon,Neko,Aroma,Castellano,One,Six,Rin,current_chapter]

def save():
  global load_and_save
  with open('sav.dat','wb') as f:
    pickle.dump(load_and_save,f,protocol=2)

def load():
  global load_and_save
  with open('sav.dat','rb') as f:
    for elem in load_and_save:
      load_and_save = pickle.load(f)

Traceback (most recent call last):
  File "main.py",line 170,in <module>
    main()
  File "main.py",line 163,in main
    load()
  File "main.py",line 85,in load
    load_and_save = pickle.load(f)
EOFError: Ran out of input

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)