With Python, can I keep a persistent dictionary and modify it?

后端 未结 7 1338
孤城傲影
孤城傲影 2020-12-16 16:23

So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file?

7条回答
  •  没有蜡笔的小新
    2020-12-16 16:44

    pickling has one disadvantage. it can be expensive if your dictionary has to be read and written frequently from disk and it's large. pickle dumps the stuff down (whole). unpickle gets the stuff up (as a whole).

    if you have to handle small dicts, pickle is ok. If you are going to work with something more complex, go for berkelydb. It is basically made to store key:value pairs.

提交回复
热议问题