我有以下代码:
cur1.execute("SELECT * FROM consommation WHERE zone=? AND date=?",(zone,date_p))
if cur1.fetchone() is not None:
abcisses+=(cur1.fetchone()[0][11:13]+'h',)
但是当我运行它时,我有一个错误:TypeError: 'NoneType' object has no attribute '__getitem__'
,而cur1.fetchone不是空的。所以我不明白为什么不起作用。有人知道为什么吗?
fetchone
获取数据并更改cursor
对象的状态,即如果只有一行要获取,则对fetchone
的下一个调用将返回None
。尝试下一个:
相关问题 更多 >
编程相关推荐