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]}")  

相关推荐

11-02 09:49
已编辑
货拉拉_测试(实习员工)
热爱生活的仰泳鲈鱼求你们别卷了:没事楼主,有反转查看图片
点赞 评论 收藏
分享
牛客网
牛客企业服务