摘要: 相关案列:某序列data=【1,3,4,5,3,4,5,3,5,6,4,6,8,9,0,4,6,7,8,9,544,2】中,找出出现次数最高的3个元素 ,他们出现次数是多少? from collection import Counter c=Counter(data) c,most_common(3 阅读全文
posted @ 2017-12-26 23:37 田坎上 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 对Python筛选字典列表里面的数据通用的做法就是迭代:比如 data=【3,45,-5,45-6,7,8,543,4,5】 res=[ ] for x in data: #一次迭代条件中的每一项然后根据条件判断。 if x <0: res.append(x) print (res) 列表解决方案: 阅读全文
posted @ 2017-12-26 22:29 田坎上 阅读(3111) 评论(0) 推荐(0) 编辑