[英]“TypeError: 'tuple' object does not support item assignment” on a list object
I imported a table from a database by using sqlite3, and then converted it to a list, even the type() function returned that the class was a list, but it still gave me that error message when I tried to change one of the cells我使用 sqlite3 从数据库中导入了一个表,然后将其转换为一个列表,即使 type() function 返回 class 是一个列表,但是当我尝试更改其中一个单元格时它仍然给了我该错误消息
Here's my code:这是我的代码:
import sqlite3
conn = sqlite3.connect('test.db')
c = conn.cursor()
c.execute("SELECT * FROM table1")
table = list(c.fetchall())
print(type(table))
table[0][0] = '10'
Output: Output:
<class 'list'>
Traceback (most recent call last):
File "PATH", line 9, in <module>
table[0][0] = '10'
TypeError: 'tuple' object does not support item assignment
Can anyone please tell me what's wrong?谁能告诉我怎么了?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.