python统计元素重复次数

2019-07-02 09:31:50 浏览数 (1)

python统计元素重复次数

代码语言:javascript复制
# !/usr/bin/python3.4
# -*- coding: utf-8 -*-

from collections import Counter

arr = ['BAISC', 'Python', 'BASICA', 'GVBASIC', 'GWBASIC', 'Python', 'ETBASIC', 'QBASIC', 'Quick', 'Basic', 'Turbo', 'Basic']

counts = list(Counter(arr).items())
print(counts)

0 人点赞