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