0
我该如何解决这个错误?当我尝试加载我保存在与泡菜它给了我这个Python 2 - TypeError:int()参数必须是字符串,类似字节的对象或数字,而不是'list'
Traceback (most recent call last):
File "C:\Users\user\Downloads\game.py", line 315, in <module>
menu()
File "C:\Users\user\Downloads\game.py", line 261, in menu
if (0) > int(hunger) or (0) > int(thirst):
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
这是我如何加载/保存
with open('objs.pickle', "rb") as f:
money = pickle.load(f)
hunger = pickle.load(f)
thirst = pickle.load(f)
energy = pickle.load(f)
wanted = pickle.load(f)
gun = pickle.load(f)
with open('objs.pickle', 'ab') as f:
pickle.dump([money, hunger, thirst, energy, gun, wanted], f)
总是在** QUESTION **中放入** FULL **错误信息。还有其他有用的信息。 – furas
我在那里编辑它 – Cube
使用'print(饥饿,渴望)'来看看你在这个变量中有什么。 – furas