tensorflow对字典排序
来源:互联网 发布:网络大电影投资90万 编辑:程序博客网 时间:2024/05/17 23:27
按照value值降序排列:
sorted(dict.items(),key=lambda k:k[1],reverse=True)
按照value值升序排序:
sorted(dict.items(),key=lambda k:k[1],reverse=False)或者sorted(dict.items(),key=lambda k:k[1])
按照key值降序排列:
sorted(dict.items(),key=lambda k:k[0],reverse=True)
按照key值升序排列:
sorted(dict.items(),key=lambda k:k[0])或者sorted(dict.items(),key=lambda k:k[0],reverse=False)
#-*- coding: utf-8 -*-file_object=open("english")dict={}for line in file_object: line=line.replace(","," ") line=line.replace("."," ") line=line.replace("!"," ") strs= line.split(); for str in strs: if dict.has_key(str): dict[str]+=1 else: dict[str]=1result=sorted(dict.items(),key=lambda k:k[1],reverse=True)print result
python读取一个英文文件,并记录每个单词出现的次数,降序输出
参考:http://www.mamicode.com/info-detail-1634632.html
阅读全文
0 0
- tensorflow对字典排序
- 对字典排序
- 对字典进行排序
- python_对字典进行排序
- [python]对字典进行排序
- python 对字典进行排序
- 【Python】Python对字典排序
- 对字典values进行排序
- Python中对字典排序
- python对字典降序排序
- 对python字典的排序
- python 对字典按value排序
- iOS中对字典进行排序
- 005_001 Python 对字典排序
- 1.13.使用Key对字典排序
- iOS中对字典进行排序
- 对python中的字典进行排序
- 如何对Map进行字典排序Java
- python3 学习笔记(一)
- 图书出版《深入Linux内核架构与底层原理》
- 如何下载UCI数据集转成arff格式的文件
- Retrofit封装
- portal是什么?
- tensorflow对字典排序
- 数据结构实验之图论七:驴友计划
- 中缀表达式转换为后缀表达式
- WinEdt调出公式编辑器
- FCC--Pig Latin(儿童黑话)
- C语言使用动态链接库静态链接库
- 关于java static 关键字
- oracle delete from和 truncate区别
- H5使用js追加表格进行操作