Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.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-TypeError:unhabable type:';列表';_Python_Python 3.x_Typeerror - Fatal编程技术网

调用另一个列表中的列表Python-TypeError:unhabable type:';列表';

调用另一个列表中的列表Python-TypeError:unhabable type:';列表';,python,python-3.x,typeerror,Python,Python 3.x,Typeerror,我试图调用另一个列表中的字符串列表,该列表在for循环中使用 lista_solic = {"name1" : "Full Name 1", "name2" : "Full Name 2", "name3" : "Full Name 3" } list_bcsulc = ["name1", "name2", "name3"] list_sol = [lista_solic[list_bcsulc]] 我将它们分为两个列表,因为稍后我

我试图调用另一个列表中的字符串列表,该列表在
for
循环中使用

lista_solic = {"name1" : "Full Name 1",
               "name2" : "Full Name 2",
               "name3" : "Full Name 3" } 
list_bcsulc = ["name1", "name2", "name3"]
list_sol = [lista_solic[list_bcsulc]]
我将它们分为两个列表,因为稍后我将在程序中单独使用它们。程序运行后,出现以下错误:

    list_sol = [lista_solic[list_bcsulc]]
TypeError: unhashable type: 'list'
当我试着把它写成元组时,它也会给我一个错误

lista_solic = {"name1" : "Full Name 1",
               "name2" : "Full Name 2",
               "name3" : "Full Name 3" } 
list_bcsulc = ("name1", "name2", "name3")
list_sol = [lista_solic[list_bcsulc]]
错误:

File "Relatorio_Filtro.py", line 160, in bcsul_contra
    list_sol = [lista_solic[list_bcsulc]]
KeyError: ('name1', 'name2', 'name3,)

问题: 如何调用另一个列表中的字符串列表从字典中获取值


list=dic[list]

无法将列表用作字典中的键。当我尝试使用parenthresis将其作为元组**()**它会给我带来另一个错误,只是列出整个元组列表\u sol=[lista\u solic[x]代表列表中的x\u bcsulc]你做错了什么。元组可以是字典键,因为它们是不可变的。请参见
list\u sol=[lista\u solic[name]了解list\u bsulc中的名称]
应该能满足您的需求。
    list_sol = [lista_solic[list_bcsulc()]]
TypeError: 'tuple' object is not callable