Skip to content

Instantly share code, notes, and snippets.

@ferstar
Last active February 26, 2020 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferstar/8f92ce5925b5ba7d524f22f94ce3faf5 to your computer and use it in GitHub Desktop.
Save ferstar/8f92ce5925b5ba7d524f22f94ce3faf5 to your computer and use it in GitHub Desktop.
code board
a_list = [
{"型号": 12, "重量": 16, "产地": 19, "审核人": 33},
{"型号": 22, "重量": 92, "产地": 87, "审核人": 34},
{"型号": 15, "重量": 27, "产地": 86, "审核人": 35},
{"型号": 71, "重量": 55, "产地": 21, "审核人": 36},
]
b_list = [
{"产地": 87, "型号": 22, "重量": 92, "审核人": 34},
{"产地": 86, "型号": 15, "重量": 27, "审核人": 35},
{"产地": 44, "型号": 65, "重量": 91, "审核人": 33},
]
def generate_key(item):
return "_".join(str(v) for k, v in item.items() if k != "型号")
hash_map = {}
for item in a_list:
hash_map.setdefault(generate_key(item), item)
for item in b_list:
hash_map.setdefault(generate_key(item), item)
c_list = list(hash_map.values())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment