【发布时间】:2018-06-29 12:12:27
【问题描述】:
我想以迭代的方式存储数据。
如何在已经包含 dict 的泡菜中添加一些新键??
例如
with open(filename_directory, 'wb') as f: pickle.dump({"a" : 1, "b":2 }, f) new_dict_ = {} for i in range(10): new_dict_ [i] = i with open(filename_directory, 'a') as f: pickle.dump( update_dict_with_my( new_dict_ ) , f)
【问题讨论】:
-
只读取文件并覆盖旧的pickle,你不能追加到pickle文件(当然不能使用文本模式)
标签: python dictionary pickle