a_list = [{'id': 1, 'value': 11}, {'id': 2, 'value': 22}, {'id': 3, 'value': 33}] b_list = [{'id': 1, 'name': 'a'}, {'id': 2, 'name': 'b'}, {'id': 3, 'name': 'c'}]
for i in range(len(b_list)): for a in a_list: if b_list[i]['id'] == a['id']: b_list[i]['value'] = a['value'] print(b_list)
[{'id': 1, 'name': 'a', 'value': 11}, {'id': 2, 'name': 'b', 'value': 22}, {'id': 3, 'name': 'c', 'value': 33}]
标签:11,name,Python,list,value,id,字典 From: https://www.cnblogs.com/zzcsza/p/16994880.html