from collections import Counter
string = 'abcdabb'
print(Counter(string).most_common())
for i,v in Counter(string).most_common():
print(str(i) + ' ' + str(v))
输出:
[('b', 3), ('a', 2), ('c', 1), ('d', 1)]
b 3
a 2
c 1
d 1
from collections import Counter
string = 'abcdabb'
print(Counter(string).most_common())
for i,v in Counter(string).most_common():
print(str(i) + ' ' + str(v))
输出:
[('b', 3), ('a', 2), ('c', 1), ('d', 1)]
b 3
a 2
c 1
d 1