How would one iterate the contents of a Shelve?
import Shelve
testShelve = Shelve.open("testShelve")
testShelve["key"] = "value"
for k in testShelve.keys():
print(k)
How would one iterate the contents of a Shelve?
import Shelve
testShelve = Shelve.open("testShelve")
testShelve["key"] = "value"
for k in testShelve.keys():
print(k)
As stated above, the Shelve object is dictionary-like and can be used the same. To print the keys and values of the testShelve object:
for key in testShelve:
print(key, testShelve[key])