如何检查目标字典是否存在于嵌套字典列表中。只需要检查特定的键详细信息和图书及其值。
target = {'details' : [{'name':'Ron','description':{'grade':'seven','section':'A'},'level':1}],
'Books':{'type':'Horror','id':101},
'version_id':{'version':10,'enable':true},
Total_marks':700}
list_of_dict = [
{'details' : [{'name':'jeff','description':{'grade':'six','section':'B'},'level':1}],
'Books':{'type':'Fiction','id':101},
'version_id':{'version':11,'enable':true},
Total_marks':900},
{'details' : [{'name':'Ron','description':{'grade':'seven','section':'A'},'level':1}],
'Books':{'type':'Horror','id':101},
'version_id':{'version':12,'enable':true},
Total_marks':700}]
任何帮助都非常感谢!
Python知道如何比较字典。
使用一个简单的:
target in list_of_dict
输出:True