我有一本嵌套字典:
Movies = {1: {'1060277': 'cloverfield', '1877830': 'The Batman', '0117283': 'The Pallbearer'},
2: {'1877830': 'The Batman', '1877321': 'The Yards', '0117283': 'The Pallbearer'},
3: {'6723592': 'Tenet', '1099212': 'Twilight', '1877830': 'The Batman'}}
现在,我想返回一个字典,它包含嵌套字典中所有字典的公共键值对,在本例中是
--> 1877830 The Batman
因为它是所有3个嵌套字典中唯一通用的一个.
我似乎搞不懂如何比较这些字典:
#mov is where Movies will be passed
def Narrow_down(mov):
final_list= mov[1]
for i in final_list.keys():
for x,y in mov.items():
for key in y:
if i==key:
print(i, "is common ")