import shelve shelf = shelve.open(filename) shelf['key1'] = value1 shelf['key2'] = value2 shelf.close() # --- shelf.open(filename) value1 = shelf['key1']
Here is what the above code is Doing:
1. Opening the shelf file
2. Storing the value of key1 in the variable value1
3. Closing the shelf file