Skip to main content
 首页 » 编程设计

python之如何解决在 dbf 中插入记录时的时间元组错误

2024年10月24日14zhujiabin

我需要在 dbf 表中插入一条新记录:

table.append(('37', '111111', '0', '0', '', '15370', '19/08/14 04:50')) 

但我收到 AttributeError: 'str' object has no attribute 'timetuple' on python。

表结构:https://i.imgur.com/ZOdovud.jpg

我正在使用 DBF 库

有什么想法吗?

请您参考如下方法:

元组中的数据应该与 dbf 所期望的相匹配。根据你的图形:

CODIGO N(3,0) 
PRODUTO C(6) 
VALOR N(14,4) 
DESC_MAX N(5,2) 
PREVISAO D 
BASE_PERC N(6,2) 
CRC N(6,0) 
DT_ACTUALIZ ? 

所以你应该传递类似的东西(只使用类型):

((int, unicode, float, float, date, float, int, ?)) 

那个?是因为我在图中看不到DT_ATUALIZ的类型。