鱼C论坛

 找回密码
 立即注册
查看: 1143|回复: 6

EOFError: Ran out of input

[复制链接]
发表于 2021-8-1 14:16:37 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. def cundang():
  2.     while 1:
  3.         try:
  4.             with open("name-instant_1.pkl","rb") as file:
  5.                 my_list=pickle.load(file)
  6.                 name =my_list[instant_1]
  7.             with open(name+".pkl","rb") as file:
  8.                 P =Protagonist()
  9.                 P.data =pickle.load(file)
  10.                 break
  11.         except (FileNotFoundError,KeyError):
  12.             name=eg.enterbox("初次登录,请输入昵称","galgame")
  13.             try:
  14.                 with open("name-instant_1.pkl","rb") as file:
  15.                     my_list =pickle.load(file)
  16.                     my_list.setdefault(instant_1,name)
  17.                 with open("name-instant_1.pkl","wb") as file:
  18.                     pickle.dump(my_list,file)
  19.             except FileNotFoundError:
  20.                 with open("name-instant_1.pkl","wb") as file:
  21.                     my_list ={}
  22.                     my_list[instant_1]=name
  23.             with open(name+".pkl","wb") as file:
  24.                     P =Protagonist()
  25.                     pickle.dump(P.data,file)
复制代码
  1. class Protagonist:
  2.     data={"背包":{},"技能":{},"money":1000,"属性":{"HP":100,"Endurance":200,"IQ":105,"EQ":100,"strenth":15},"技能树":{}}
  3.     def sleep(self):
  4.         self.data["属性"]["HP"]=100
  5.         self.data["属性"]["Endurance"]=100
复制代码



求解
Traceback (most recent call last):
  File "D:\my game\my first game.py", line 391, in <module>
    cundang()
  File "D:\my game\my first game.py", line 108, in cundang
    my_list=pickle.load(file)
EOFError: Ran out of input

这又是什么错误
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-8-1 14:18:35 | 显示全部楼层
对了 instant_1是一个字符串
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-8-1 14:24:26 | 显示全部楼层
新人求上岸 发表于 2021-8-1 14:18
对了 instant_1是一个字符串

代码不完整哦,上传完整代码代码不完整,很难找问题
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-8-1 14:27:06 | 显示全部楼层
  1. def register():
  2.     def go():
  3.         while 1:
  4.             global start,instant_1
  5.             msg = "请输入用户名和密码"
  6.             title ="galgame"
  7.             choices = ["用户名","密码"]
  8.             des_1=eg.multpasswordbox(msg,title,choices)
  9.             try:
  10.                 if user_account_password[des_1[0]] != des_1[1]:
  11.                     des_2=eg.buttonbox("用户名或密码错误","galgame",["注册","返回"])
  12.                     if des_2=="注册":
  13.                         eg.msgbox("加载中....")
  14.                         wait()
  15.                         break
  16.                     else:
  17.                         continue
  18.                 else:
  19.                     instant_1 =des_1[0]
  20.                     start = True
  21.                     break
  22.             except KeyError:
  23.                 des_2=eg.buttonbox("用户名不存在","galgame",["注册","返回"])
  24.                 if des_2=="注册":
  25.                     eg.msgbox("加载中....")
  26.                     wait()
  27.                     break
  28.                 else:
  29.                     continue


  30.     def wait():
  31.         while 1:
  32.             msg = "请输入用户名和密码"
  33.             title ="galgame"
  34.             choices = ["用户名","密码"]
  35.             des_1=eg.multpasswordbox(msg,title,choices)
  36.             if des_1[0] in user_account_password:
  37.                 des_2=eg.buttonbox("用户名已存在","galgame",["登录","返回"])
  38.                 if des_2=="登录":
  39.                     go()
  40.                     break
  41.                 else:
  42.                     continue
  43.             else:
  44.                 user_account_password[des_1[0]]=des_1[1]
  45.                 break
  46.     def cancel():
  47.         while 1:
  48.             msg = "请输入需要注销的用户名和密码"
  49.             title ="galgame"
  50.             choices = ["用户名","密码"]
  51.             des_1=eg.multpasswordbox(msg,title,choices)
  52.             try:
  53.                 if des_1[0]==des_1[1]:
  54.                     user_account_password.pop(des_1[0])
  55.                     break
  56.                 else:
  57.                     eg.msgbox("输入的用户名或密码错误","galgame",ok_button="返回")
  58.                     continue
  59.             except KeyError:
  60.                 eg.msgbox("用户名不存在","galgame",ok_button="返回")
  61.                 continue
  62.             
  63.     def save():
  64.         with open("user_account_password.pkl","wb") as pickle_file:
  65.                 pickle.dump(user_account_password,pickle_file)



  66.             
  67.     with open("user_account_password.pkl","rb") as pickle_file:
  68.         user_account_password = pickle.load(pickle_file)
  69.     global start,instant_1
  70.     start =False
  71.     while 1:
  72.         msg="欢迎体验小游戏"
  73.         title="galgame"
  74.         choices = ["登录","注册","注销","退出"]
  75.         decision = eg.buttonbox(msg,title,choices)
  76.         if decision=="登录":
  77.             go()
  78.             save()
  79.             break
  80.         elif decision=="注册":
  81.             wait()
  82.             save()
  83.             continue
  84.         elif decision=="注销":
  85.             cancel()
  86.             save()
  87.             continue
  88.         else:
  89.             print("感谢游玩")
  90.             break
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-8-1 14:27:48 | 显示全部楼层
1q23w31 发表于 2021-8-1 14:24
代码不完整哦,上传完整代码代码不完整,很难找问题

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-8-1 14:31:16 | 显示全部楼层
register()
if start:
    eg.msgbox("登录成功","galgame")
    cundang()
    while 1:
        home()
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-8-1 14:43:11 | 显示全部楼层
0.0 问题已解决
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-3 04:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表