{"id":5101,"date":"2020-07-15T18:56:26","date_gmt":"2020-07-15T18:56:26","guid":{"rendered":"https:\/\/davelevy.info\/wiki\/?p=5101"},"modified":"2023-01-02T11:09:32","modified_gmt":"2023-01-02T11:09:32","slug":"python-pickle","status":"publish","type":"post","link":"https:\/\/davelevy.info\/wiki\/python-pickle\/","title":{"rendered":"Python\/pickle"},"content":{"rendered":"<p>Some notes on Python Pickle. See below\/overleaf.<!--more--><\/p>\n<p>It reminds me of tape files, seems to be only open in read or write mode.<\/p>\n<pre>dictfile = open('bookmarks.pickle','rb')\r\nD = {};                     # the input dictionary\r\nD = pickle.load(dictfile) ; # loads a dictionary\r\ndictfile.close();           # so the db can be opened for writing\r\n<\/pre>\n<p>This code works, you seem to need to close it before it permits you to open the pickle file in write mode.<\/p>\n<pre>duff=2846\r\ndel D[duff]\r\n\r\ndictfile = open('bookmarks.pickle','wb')\r\npickle.dump(D,dictfile)\r\ndictfile.close()\r\n<\/pre>\n<p>In all the cases above, there is room for substitution, but this works.<\/p>\n<p>I use the statement <code>import pickle<\/code>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some notes on Python Pickle. See below\/overleaf.<\/p>\n","protected":false},"author":1,"featured_media":5102,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_share_on_mastodon":"0"},"categories":[3],"tags":[1495,45,911],"class_list":["post-5101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-pickle","tag-python","tag-technology"],"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"https:\/\/davelevy.info\/wiki\/wp-content\/uploads\/2020\/07\/pickle-unsplash-alexvoulgaris-w650-cropped.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/5101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/comments?post=5101"}],"version-history":[{"count":0,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/5101\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media\/5102"}],"wp:attachment":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media?parent=5101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/categories?post=5101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/tags?post=5101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}