Python dict词典排序
来源:互联网 发布:门板雕刻生产软件 编辑:程序博客网 时间:2024/05/21 08:54
整理一下key排序和value排序
- key
tmpdict = {"1":20,"2":50,"3":40,"4":100,"5":80}# key从大到小>>> for i in sorted(tmpdict.keys(),reverse=True):... print([i,tmpdict[i]])... ['5', 80]['4', 100]['3', 40]['2', 50]['1', 20]
- value
>>> tmpdict = {"1":20,"2":50,"3":40,"4":100,"5":80}# value从大到小>>> orderdict = sorted(tmpdict.items(),key=lambda item:item[1],reverse=True)>>> orderdict[('4', 100), ('5', 80), ('2', 50), ('3', 40), ('1', 20)]
阅读全文
0 0
- Python dict词典排序
- 1.Python进阶 词典dict
- Python Dict 词典的用法
- Python Dict 排序
- python dict sorted 排序
- python dict排序之一
- python dict sorted 排序
- python dict sorted 排序
- python dict排序
- python dict sorted 排序
- python dict 排序
- python dict排序
- python dict按照value 排序
- python dict按照value 排序
- python dict list 排序专题
- python dict按照value 排序
- python dict 按key排序
- python dict按照value 排序
- Cg语言中文说明文档(二)
- pip错误:TypeError: parse() got an unexpected keyword argument 'transport_encoding'
- 安装MySQL解压版
- HTTP状态码
- Jenkins自动部署maven项目到tomcat
- Python dict词典排序
- Qt 键盘、鼠标事件的处理
- 不想git更新代码时产生merge记录,可以使用git rebase命令
- 计算机网络一些题
- Servlet 生命周期、工作原理
- 微信授权登录-前后端分离
- 更新所有pip安装的程序
- Vue报错笔记(1)vue.js:515 [Vue warn]: Property or method "name" is not defined on the instance but refere
- python的ID方法