我怎么才能用泡菜来拯救一个混蛋呢?我查阅了Python文档给,但我还是有点困惑。有人可以发布示例代码来编写一个新文件,然后使用泡菜将字典转储到其中吗?
3 回答

噜噜哒
TA贡献1784条经验 获得超7个赞
import pickle a = {'hello': 'world'}with open('filename.pickle', 'wb') as handle: pickle.dump(a, handle, protocol=pickle.HIGHEST_PROTOCOL)with open('filename.pickle', 'rb') as handle: b = pickle.load(handle)print a == b
添加回答
举报
0/150
提交
取消