我有这个代码。
cursor.execute("select id, name from client")
clientids= cursor.fetchall()
clientidList = []
for clientid in clientids:
#I can do that
clientidList.append(clientid [0])
#but I can't do that.
clientidList.append(clientid ['id'])
第二次尝试我得到一个错误,TypeError: 'tuple' object is not callable
知道为什么这是不可能的吗?有没有其他方法可以实现这一点,因为当我放置属性名称而不是索引时,它更全面,恰好在输出超过 20 列的查询中。我试过这个,但它对我不起作用
谢谢!