统计一组数据的次数
Posted yymhaha
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了统计一组数据的次数相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
# coding=utf-8
aa = open(‘C:/Users/12041/Desktop/text.txt‘,‘r‘,encoding=‘utf-8‘)
a = []
while True:
line = aa.readline().strip()
if line:
a.append(line)
else:
break
b = list(set(a))
for i in b:
print("%s has %s"%(i,a.count(i)))
以上是关于统计一组数据的次数的主要内容,如果未能解决你的问题,请参考以下文章