Python中找list中最大n个数的包heapq.nlargest
2016-06-18 15:59
417 查看
from heapq import nlargest
a = [0.2, 0.9, 0.5, 1.1, 1.5, 2.3]
print nlargest(4, a) #从list a中找出最大的四个数
a = [0.2, 0.9, 0.5, 1.1, 1.5, 2.3]
print nlargest(4, a) #从list a中找出最大的四个数
相关文章推荐
- 257. Binary Tree Paths [easy] (Python)
- 双色球 python
- 搞不懂 numpy.sum 请过来
- 记录
- python用openpyxl操作excel
- python用openpyxl操作excel
- 第四章 Python外壳:代码结构
- Python中使用装饰器来优化尾递归的示例
- sublime 3 注册码+PYTHON 环境配置+pylint插件path问题+package control找不到packages解决方法。
- 决策树
- 以图搜图(一):Python实现dHash算法(转)
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制
- Python爬虫入门之request函数定制