Created
February 17, 2014 03:37
-
-
Save davidbj/9044298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I.pickle exmaple | |
| """object save to file.""" | |
| import pickle | |
| obj = Someobject() | |
| f = open(filename, 'wb') | |
| pickle.dump(obj, f) | |
| f.close() | |
| """load file value""" | |
| import pickle | |
| f = open(filename, 'rb') | |
| obj = pickle.load(f) | |
| f.close() | |
| II.shelve example | |
| import shelve | |
| obj = SomeObject() | |
| db = shelve.open("filename") | |
| db['key'] = obj | |
| obj = db['key'] #index object value | |
| db.close() #close shelve and save to filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment