Python数组统计排序问题
来源:互联网 发布:matlab读取excel数据 编辑:程序博客网 时间:2024/06/08 07:05
这里使用Counter这个类,很容易,只要采用使用lambda函数,很容易解决
from collections import Countertimes_intervals = [1,2,3,4,5,5,6,6]times_count = Counter(times_intervals)print times_counttimes_sorted = sorted(times_count.items(), key=lambda x:x[0])print times_sortedprint [t[0] for t in times_sorted]>>> Counter({5: 2, 6: 2, 1: 1, 2: 1, 3: 1, 4: 1})[(1, 1), (2, 1), (3, 1), (4, 1), (5, 2), (6, 2)][1, 2, 3, 4, 5, 6]
阅读全文
0 0
- Python数组统计排序问题
- Python numpy数组排序问题
- Python 二维数组排序问题
- python统计数组元素出现次数以及排序
- python:numpy数组运算、排序、统计、随机数生成
- python 统计数组中元素出现次数并进行排序
- python学习笔记:二维数组排序问题
- Python字符串统计以及排序
- python 二维数组排序
- python数组排序
- python 数组排序
- 字符统计&大数乘法&数组排序
- 数组排序的问题
- C#数组排序问题
- java数组排序问题
- 数组的排序问题。
- 一道数组排序问题
- 数组排序问题
- 学习日记-jq获取浏览器长和宽
- JS设置cookie、读取cookie、删除cookie
- Halcon学习之二:摄像头获取图像和相关参数
- 完全二分图的最大边数
- 理财学习与思考
- Python数组统计排序问题
- 中国联通大数据应用
- (M)Dynamic Programming:377. Combination Sum IV
- 复习一下指针
- 多线程:创建Thread为什么要调用start启动,而不能直接调用run方法
- python json和java json的使用
- C++ 数组
- 10月 5日 c语言 一维数组 处理Fibonacci 数列问题
- 128. Longest Consecutive Sequence(最长连续序列)