简单操作: import collections A=['a','b','b','c','d','b','a'] count=collections.Counter(A) print(count) Counter({'b': 3, 'a': 2, 'c': 1, 'd': 1}) count.items() Out[6]: dict_items([('a', 2), ('b', 3), ('c', 1), ('d', 1)]) count.keys() Out[7]: dict_keys(['a…