python 列表中dict中key排序
生活随笔
收集整理的這篇文章主要介紹了
python 列表中dict中key排序
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#1列表排序:使用lamada表達式進行排序
student_new=[{'id':1,'name':'無語1','english':100,'python':98},{'id':2,'name':'無語2','english':87,'python':96},{'id': 3, 'name': '無語3', 'english': 95, 'python': 100}]student_new.sort(key=lambda x:x['english'],reverse=True)
print(student_new)
輸出結果:
[{‘id’: 1, ‘name’: ‘無語1’, ‘english’: 100, ‘python’: 98}, {‘id’: 3, ‘name’: ‘無語3’, ‘english’: 95, ‘python’: 100}, {‘id’: 2, ‘name’: ‘無語2’, ‘english’: 87, ‘python’: 96}]
總結
以上是生活随笔為你收集整理的python 列表中dict中key排序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UserWarning: Matplot
- 下一篇: python模块下载过程_常用的pyth