EOFError: Ran out of input
def cundang():while 1:
try:
with open("name-instant_1.pkl","rb") as file:
my_list=pickle.load(file)
name =my_list
with open(name+".pkl","rb") as file:
P =Protagonist()
P.data =pickle.load(file)
break
except (FileNotFoundError,KeyError):
name=eg.enterbox("初次登录,请输入昵称","galgame")
try:
with open("name-instant_1.pkl","rb") as file:
my_list =pickle.load(file)
my_list.setdefault(instant_1,name)
with open("name-instant_1.pkl","wb") as file:
pickle.dump(my_list,file)
except FileNotFoundError:
with open("name-instant_1.pkl","wb") as file:
my_list ={}
my_list=name
with open(name+".pkl","wb") as file:
P =Protagonist()
pickle.dump(P.data,file)
class Protagonist:
data={"背包":{},"技能":{},"money":1000,"属性":{"HP":100,"Endurance":200,"IQ":105,"EQ":100,"strenth":15},"技能树":{}}
def sleep(self):
self.data["属性"]["HP"]=100
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
这又是什么错误{:5_100:} {:5_100:} 对了 instant_1是一个字符串 新人求上岸 发表于 2021-8-1 14:18
对了 instant_1是一个字符串
代码不完整哦,上传完整代码代码不完整,很难找问题 def register():
def go():
while 1:
global start,instant_1
msg = "请输入用户名和密码"
title ="galgame"
choices = ["用户名","密码"]
des_1=eg.multpasswordbox(msg,title,choices)
try:
if user_account_password] != des_1:
des_2=eg.buttonbox("用户名或密码错误","galgame",["注册","返回"])
if des_2=="注册":
eg.msgbox("加载中....")
wait()
break
else:
continue
else:
instant_1 =des_1
start = True
break
except KeyError:
des_2=eg.buttonbox("用户名不存在","galgame",["注册","返回"])
if des_2=="注册":
eg.msgbox("加载中....")
wait()
break
else:
continue
def wait():
while 1:
msg = "请输入用户名和密码"
title ="galgame"
choices = ["用户名","密码"]
des_1=eg.multpasswordbox(msg,title,choices)
if des_1 in user_account_password:
des_2=eg.buttonbox("用户名已存在","galgame",["登录","返回"])
if des_2=="登录":
go()
break
else:
continue
else:
user_account_password]=des_1
break
def cancel():
while 1:
msg = "请输入需要注销的用户名和密码"
title ="galgame"
choices = ["用户名","密码"]
des_1=eg.multpasswordbox(msg,title,choices)
try:
if des_1==des_1:
user_account_password.pop(des_1)
break
else:
eg.msgbox("输入的用户名或密码错误","galgame",ok_button="返回")
continue
except KeyError:
eg.msgbox("用户名不存在","galgame",ok_button="返回")
continue
def save():
with open("user_account_password.pkl","wb") as pickle_file:
pickle.dump(user_account_password,pickle_file)
with open("user_account_password.pkl","rb") as pickle_file:
user_account_password = pickle.load(pickle_file)
global start,instant_1
start =False
while 1:
msg="欢迎体验小游戏"
title="galgame"
choices = ["登录","注册","注销","退出"]
decision = eg.buttonbox(msg,title,choices)
if decision=="登录":
go()
save()
break
elif decision=="注册":
wait()
save()
continue
elif decision=="注销":
cancel()
save()
continue
else:
print("感谢游玩")
break 1q23w31 发表于 2021-8-1 14:24
代码不完整哦,上传完整代码代码不完整,很难找问题
嗯 register()
if start:
eg.msgbox("登录成功","galgame")
cundang()
while 1:
home() 0.0 问题已解决
页:
[1]