我正在尝试将字典添加到搁置文件中:
>>> d = shelve.open('index.shelve')
>>> d
<shelve.DbfilenameShelf object at 0x21965f0>
>>> print(list(d.keys()))
[]
>>> d['index'] = index
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/bns/rma/local/python/lib/python3.1/shelve.py", line 124, in __setitem__
self.dict[key.encode(self.keyencoding)] = f.getvalue()
_dbm.error: cannot add item to database
索引有点大但不是很大。它本质上是一个浮点数组:
>>> len(index)
219
>>> a = [ index[k][k1] for k in index for k1 in index[k] ]
>>> len(a)
59995
>>> all([ type(x) is float for x in a ])
True
这是什么错误?此外,我应该在模块或模块文档中的某个地方获取有关错误代表的更多信息吗?错误信息不是很丰富,至少对我来说:)。