I. Introduction of SHELVE
1, shelve is a simple data storage scheme, he has only one function is open (), the function receives a parameter is the file name, and then return a shelf object, you can use him to store things, you can simply think of him as a dictionary, when you are stored, Just call the close function to close the
2, shelve module is a simple k,v memory data through the file persistence module, you can persist any pickle can support the Python data format
Second, examples
Import shelve,datetimed = Shelve.open (' E:\python-project\\f7 ') # Open a file print (D.get (' name ')) print (D.get (' info ') Print (D.get (' Date ')) info = {' age ': ' + ', ' job ': ' it '}name = ["Alex", "Rain", "Test"]d["name"] = name # persistent list d["info"] = Info # persistence class d["date"] = Datetime.datetime.now () d.close ()
Python built-in module (shelve)--035