我在这里使用一种古老的数据库格式,dbf 文件。不要问为什么,只知道某个软件决定扩展foxpro支持,因为微软决定扩展foxpro支持。现在,我在特定文件上收到以下错误。我已成功加载另一个文件,我很好奇该数据库是否有问题。我确信您可能需要查看数据库来确定这一点,但它的发布方式太大了,所以我会采取我能得到的。
Traceback (most recent call last):
File "billsapi.py", line 250, in <module>
x.getUsedGuns()
File "billsapi.py", line 72, in getUsedGuns
itemdb = dbf.Dbf('item.dbf', readOnly=True, ignoreErrors=True)
File "C:\Python27\lib\site-packages\dbfpy\dbf.py", line 135, in __init__
self.header = self.HeaderClass.fromStream(self.stream)
File "C:\Python27\lib\site-packages\dbfpy\header.py", line 127, in fromStream
_fld = fields.lookupFor(_data[11]).fromString(_data, _pos)
File "C:\Python27\lib\site-packages\dbfpy\fields.py", line 455, in lookupFor
return _fieldsRegistry[typeCode]
KeyError: '0'
这是返回此错误的简单代码:
def getUsedGuns(self):
itemdb = dbf.Dbf('item.dbf', readOnly=True, ignoreErrors=True)
就像我说的,我可以毫无问题地加载其他文件,但也许有解决这个特定错误的方法?
EDIT:我还想指出的是,该文件可以在 DBF View Plus 中打开、查看和修改。