我有一个字典列表,并希望找到匹配的列表元素(元素是一个完整的字典)。不知道如何在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