Python 官方文档:入门教程 => 点击学习
dict = [{'id':'4','name':'b'},{'id':'6','name':'c'},{'id':'3','name':'a'},{'id':'1','name':'g'},{'id':'8','name':'f'}]di
dict = [
{'id':'4','name':'b'},
{'id':'6','name':'c'},
{'id':'3','name':'a'},
{'id':'1','name':'g'},
{'id':'8','name':'f'}
]
dict_b = sorted(dict, key=lambda a:a['id'])
print dict_b
排序后:[{'id': '1', 'name': 'g'}, {'id': '3', 'name': 'a'}, {'id': '4', 'name': 'b'}, {'id': '6', 'name': 'c'}, {'id': '8', 'name': 'f'}]
--结束END--
本文标题: python sorted 和 lamb
本文链接: https://lsjlt.com/news/187619.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0