(1)列表中的count方法(速度慢)
#嵌套列表类型的统计
l = [[1,2,3,4,5],[1,2,3,4,5],[5,6,7,8,9]]
dictionary= {}
s = set(l)
for i in s:
dict[i] = l.count(i)
(2)字典(速度慢)
l = [[1,2,3,4,5],[1,2,3,4,5],[5,6,7,8,9]]
dict = {}
for i in l:
if i in dict.keys():
dict[i] = int(dict[i]) +1
else:
dict[i] = 1
(3)Counter(速度快)
l = [[1,2,3,4,5],[1,2,3,4,5],[5,6,7,8,9]]
cnt = Counter()
for i in l:
i = tuple(i)
cnt[i] += 1