code board
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
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