Py学习  »  Python

Python从另一个字典列表更新字典列表中的值

bayman • 5 年前 • 1203 次点击  

如果给定下面两个词典列表(score_list和update_list),如何从update_list中的词典列表更新score_list?

score_list = [{'id': 1, 'score': 123}, {'id': 2, 'score': 234}, {'id': 3, 'score': 345}]

update_list = [{'id': 1, 'score': 500}, {'id': 3, 'score': 300}]

# return this
score_list = [{'id': 1, 'score': 500}, {'id': 2, 'score': 234}, {'id': 3, 'score': 300}]
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52115
 
1203 次点击  
文章 [ 1 ]  |  最新文章 5 年前