微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

EOFError:加载时跑出输入

如何解决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 举报,一经查实,本站将立刻删除。