猿问

我怎么才能用泡菜来拯救一个混蛋呢?

我怎么才能用泡菜来拯救一个混蛋呢?

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



ITMISS
浏览 383回答 3
3回答

噜噜哒

试试这个: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
随时随地看视频慕课网APP

相关分类

Python
我要回答