Retrieving Entries from a DBM File : DBM « Database « Python Tutorial






import anydbm

cityDB = anydbm.open("city.dbm", 'r')
timeDB = anydbm.open("time.dbm", 'r')

flights = cityDB.keys()

print "Arrivals"
for flight in flights:
    print ("Flight %s arrives from %s at %s" % (flight, cityDB[flight], timeDB[flight]))


cityDB.close()
timeDB.close()








15.2.DBM
15.2.1.Adding Entries to a DBM File
15.2.2.Retrieving Entries from a DBM File