0

本の演習の一部として「dbm」モジュールを調べるのはこれが初めてですが、なぜこのエラーが発生するのかわかりません。

import dbm

db = dbm.open('chapt14/dbtest/captions', 'c')
db['cleese.png'] = 'Photo of John Cleese'
db['testeroni.png'] = 'Photo of Cohn Jleese'

for key in db:
    print(key, db[key])
db.close()
Traceback (most recent call last):
  File "/home/individuation/Documents/Code/ThinkPython/chapt14/dbtest/db_test.py", line 7, in <module>
    for key in db:
TypeError: '_gdbm.gdbm' object is not iterable
4

0 に答える 0