我正在嘗試使用pickle爲我的遊戲創建一個保存文件,但是當我嘗試提交我的字典,然後再取回該信息,但它不工作。 import pickle
data = {'health':100, 'gold':1560, 'name': 'mariano'}
with open('s.txt','wb') as f:
pickle.dump(data, f, protocol = 2)
wi
with open('data', 'w') as f:
pickle.dumps({'foo':111},f)
結果 an integer is required (got type _io.TextIOWrapper)
我該如何解決這個問題? 我很肯定An integer is required? open()事先沒有被調用。 Python版本是3.6.2