我有一個字典列表,並希望找到匹配的列表元素(元素是一個完整的字典)。不知道如何在Python中做到這一點。匹配字典列表中的整個元素python
以下是我需要:
list_of_dict = [ {a : 2, b : 3, c : 5}, {a : 4, b : 5, c : 5}, {a : 3, b : 4, c : 4} ]
dict_to_match = {a : 4, b : 5, c : 5}
所以上面輸入dict_to_match
應該匹配在列表中的第二個元素list_of_dict
一些能幫助一個與這個問題一個很好的解決方案呢?
'如果dict_to_match in list_of_dict:' –
如果你只是想知道如何比較2個字母:http://stackoverflow.com/questions/4527942/comparing-two-dictionaries-in-python – roymustang86