Last active
August 23, 2017 06:17
-
-
Save nooperpudd/d0e3dd897b75a821e7a21823a5fd6113 to your computer and use it in GitHub Desktop.
dict common keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_dict_common_keys(dict_list): | |
""" | |
check the dict common keys in the dict list | |
:param dict_list: [{},{}...] | |
:return: set() | |
""" | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment