我正在尝试使用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