我需要访问列表中的列表元素
我尝试了以下代码:
connections ={}
for i in connections_with_names:
connections['dog']=[dict1[i] for i in dict2[i] if i not in connections_with_names[0]['dog']]
但我回来了:
KeyError: 0
此外,connections_with_names['dog']
看起来像这样:
[['furry',
'loud',
'shed']]
我需要for i in dict2[i] if i not in connections_with_names[0]['dog']]
能够访问3个元素(furry、loud、shed)并排除这些元素。我认为这个问题与connections_with_names[0]
部分有关,但不确定
目前没有回答
相关问题 更多 >
编程相关推荐