Counter是dict的子类,一般用于统计,默认排序是从大到小 from collections import Counter # 输入iterable对象即可 str_counter = Counter('dgwjgdsjgdjksgdsjgdgshfdsghfd') # 直接统计出结果,吊了一逼 print(str_counter) # Counter({'d': 7, 'g': 7, 's': 5, 'j': 4, 'h': 2, 'f': 2, 'w': 1, 'k': 1}) # u…