Some notes on Python Pickle. See below/overleaf.

It reminds me of tape files, seems to be only open in read or write mode.

dictfile = open('bookmarks.pickle','rb')
D = {};                     # the input dictionary
D = pickle.load(dictfile) ; # loads a dictionary
dictfile.close();           # so the db can be opened for writing

This code works, you seem to need to close it before it permits you to open the pickle file in write mode.

duff=2846
del D[duff]

dictfile = open('bookmarks.pickle','wb')
pickle.dump(D,dictfile)
dictfile.close()

In all the cases above, there is room for substitution, but this works.

I use the statement import pickle.

 

Dave Technology , ,

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.