Python Pickle Help -
I'm not sure why this pickle example is not showing both definitions as I understand it, "now + "Means that the Pickle.dat file has been added and can be read from it. I am totally new to the coconut concept, but the tutorial on the net does not look beyond just the initial storage.
import cickle def aspen_object (d, fname): "" "fname" with a pickle dash of dash "print" append_hesh ", open (fname, 'ab') with Flickr Adding as a picker: pickle.dump (D, picker) db_file = 'pickle.dat' cartoon = () Cartoon ['Mouse'] = 'Mikey' Append_Object (cartoon, db_file) Cartoon = {} Cartoon [' Bird '] =' Tweety 'Append_Object (cartoon, DB_file) Open with' loading from loader 'print (DB_file,' RB ') as picker: Cartoon = Picail. Ideally, I was hoping to make a dictionary using a dictionary for the loop and then the key: in the Pickle.dat file (Pikelar) print 'load', cartoon
To add some value, then clear the dictionary to save some RAM.
What's going on here?
Do not use pickle for this. Use a database.
Python to fully fit what you want It seems to offer you a dictionary-like interface, but the data is saved on disk.
Example Usage:
& gt; & Gt; & Gt; Import DBM & gt; & Gt; & Gt; X = dbm.open ('/ tmp / foo.dat', 'c') & gt; & Gt; & Gt; X ['mouse'] = 'Mikey' & gt; & Gt; & Gt; X ['Bird'] = 'Tweety'
You can load the data yesterday:
& gt; & Gt; & Gt; Import DBM & gt; & Gt; & Gt; X = dbm.open ('/ tmp / foo.dat', 'c') & gt; & Gt; & Gt; Print X ['Mouse'] Mikey & gt; & Gt; & Gt; Print X ['Bird'] Tweety
Comments
Post a Comment