Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dict_common_keys(dict_list):
- """
- check python dict list common keys
- :param dict_list: [{},{}...]
- :return:
- """
- if len(dict_list) >= 2:
- common_keys = set(dict_list[0].keys())
- for dict_item in dict_list[1:]:
- common_keys.intersection_update(set(dict_item.keys()))
- return common_keys
- a={"a":"b","c":"d"}
- b={"c":"e","f":"g","a":"dd"}
- c={"a":"f","c":"cc"}
- check_dict_conflict([a,b,c])
- # output: {'a', 'c'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement