1. 程式人生 > >統計一組數據的次數

統計一組數據的次數

odi line pre int encoding des %s lse AC

#!/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)))

統計一組數據的次數