酷代码 AI
菜单
服务商

Python代码:统计文本中各单词出现次数,去除空格与标点

```python text = "now is the time in the past is the time to get down to the now is the time to work hard for the" words = text.split() word_count = {} for word in words: if word in word_count: word_count[word] += 1 else: word_count[word] = 1 for word, count in word_count.items(): print(f"{word}: {count}") ``` ######[AI写代码神器 | 103点数解答 | 2024-10-24 15:12:07]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]