可以使用 Python 内置的 collections
模块,调用它的 Counter
函数,它可以计算出一个单词中同一字母的重复次数,比如:```python from collections import Counterword = 'mississippi' Counter(word)# 输出:
Counter({'i': 4, 's': 4, 'p': 2, 'm': 1})
```
可以使用 Python 内置的 collections
模块,调用它的 Counter
函数,它可以计算出一个单词中同一字母的重复次数,比如:```python from collections import Counterword = 'mississippi' Counter(word)# 输出:
```