Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将元组转换为列表不起作用_Python_List_Sqlite_Formatting_Tuples - Fatal编程技术网

Python 将元组转换为列表不起作用

Python 将元组转换为列表不起作用,python,list,sqlite,formatting,tuples,Python,List,Sqlite,Formatting,Tuples,我使用循环查询SQlite数据库以从中检索数据 connector = sqlite3.connect("somedb.db") selecter = connector.cursor() selecter.execute(''' SELECT somedata FROM somedb''') for row in selecter: l = list(row) print (l) print (type(l)) 然后我尝试使用格式将检索到的数据附加到其他内容 this

我使用循环查询SQlite数据库以从中检索数据

connector = sqlite3.connect("somedb.db")
selecter = connector.cursor()
selecter.execute(''' SELECT somedata FROM somedb''')
for row in selecter:
    l = list(row)
    print (l)
    print (type(l))
然后我尝试使用格式将检索到的数据附加到其他内容

this = detect.that( "{}", pick, summary).format(l)
但它又回来了:

AttributeError: 'tuple' object has no attribute 'format'
我也试过这个

s = " ".join(str(row) for row in selecter)
对于
l=list(row)
语句,它返回的是相同的错误消息,似乎它将我所有的50个单独的选择转换成了一个字符串,而我不想要这个字符串

然而,当我运行这个

print (type(l))

它将我作为类型返回
list
string
。因此转换成功了,但是
.format
不接受它,因为它认为它是一个元组


怎么回事?

将您的
检测更改为以下内容:

this = str(detect.that("{}", pick, summary)).format(1)

显然
detect.that
返回一个元组,而不是一个字符串。我不能在那里插入
元组。这也不起作用。仍然是相同的错误消息修复了它,再试一次。我没有忘记它。我有好几天不在家。等我回到家里再试试!这也行不通。现在我得到了这个错误:“ValueError:太多的值无法解包(预期为5个)”
this = str(detect.that("{}", pick, summary)).format(1)