要统计一段文字中的单词个数,我们需要先对文字进行分词处理,然后统计不同单词的数量。在Python中,我们可以使用collections.Counter类来方便地实现这一点。 python from collections import Counter def count_words(text): # 使用空格对文本进行分词 words = text.split() # 使用Counter统计每个单词出现的次数 word_...