Python shelve Module
Example
Demonstrate shelve dictionary-like interface:
import shelve
# Shelve provides a dictionary-like persistent storage
data = {'name': 'Emil', 'age': 25}
print(f"Data to store: {data}")
print('Use shelve.open() to persist this data to disk')
Try it Yourself »
Definition and Usage
The shelve module provides a simple persistent dictionary-like object for storing Python objects.
Use it to save and retrieve Python objects to/from disk using a dictionary-like interface backed by a database.
Members
Member | Description |
---|---|
DbfilenameShelf | Shelf implementation using a specific database filename. |
Shelf | Base class for shelf implementations. |
open() | Open a persistent dictionary for reading and writing. |