将查询参数指定为python中查询返回的列表的名称 变量列表“列表ID”。 这个id是我想要的列表名。 list_ids= [1,44,37] for id in list_ids: cursor.execute("SELECT distinct

将查询参数指定为python中查询返回的列表的名称 变量列表“列表ID”。 这个id是我想要的列表名。 list_ids= [1,44,37] for id in list_ids: cursor.execute("SELECT distinct,python,Python,将查询参数指定为python中查询返回的列表的名称 变量列表“列表ID”。 这个id是我想要的列表名。 list_ids= [1,44,37] for id in list_ids: cursor.execute("SELECT distinct [instance] from table where id=?",id) row = cursor.fetchall() instances = [rw[0] for rw in row] print instan

将查询参数指定为python中查询返回的列表的名称 变量列表“列表ID”。 这个id是我想要的列表名。
list_ids=  [1,44,37]
for id in list_ids:
    cursor.execute("SELECT distinct [instance] from table where id=?",id) 
    row = cursor.fetchall()
    instances = [rw[0] for rw in row]
    print instances
这为列表“列表ID”的3个元素生成了3个不同的列表。
尝试将列表“list_id”的3个元素指定为生成列表的名称。这将返回3个列表,如[1,2,3,4,5,6,7,8,9,10,11,12,13,14][1,2,3,4,5,6][1,2,3,4,5,6,7,8]如何获取;list_1=[1,2,3,4,5,6,7,8,9,10,11,12,13,14]list_44=[1,2,3,4,5,6]list_37=[1,2,3,4,5,6,7,8]请注意,list_ID是一个变量列表,列表中的列表元素数量不同。你有问题吗?编辑:编辑您的原始帖子以包含问题。如何获取:list_1=[1,2,3,4,5,6,7,8,9,10,11,12,13,14]list_44=[1,2,3,4,5,6]list_37=[1,2,3,4,5,6,7,8]它如何返回3个列表?它们是否也在列表中?它是否返回[[1,2,3,4,5,6,7,8,9,10,11,12,13,14][1,2,3,4,5,6][1,2,3,4,5,5,6,7,8]?在这种情况下,您可以执行list_1、list_44、list37=get_instance()否,它们作为迭代器“for id In list_id:”下的查询显示为3个不同的列表,我正在迭代器中打印