s = "hello world how are you" words = s.lower().split() # 将所有单词转换为小写 word_count = {} for word in words: if word in word_count: word_count[word] += 1 else: word_count[word] = 1 sorted_words = sorted(word_count.keys()) for word in sorted_words: print(f"{word}: {word_count[word]}")