Code: Alles auswählen
>>> s = shelve.open("/tmp/s")
>>> s["a"] = {}
>>> s["a"]["b"] = 42
>>> s
{'a': {}}
>>> s["a"]["b"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'b'
>>> s["a"]
{}
shelve Doku hat geschrieben:values (not the keys!) in a shelf can be essentially arbitrary Python objects -- anything that the pickle module can handle
pickle Doku hat geschrieben:The following types can be pickled:
* None, True, and False
* integers, long integers, floating point numbers, complex numbers
* normal and Unicode strings
* tuples, lists, sets, and dictionaries containing only picklable objects
[...]