直接给kimi 让它识别需求
import re
from collections import Counter
def wordcount(text):
# 使用正则表达式去除非字母字符并将所有字符转换为小写
words = re.findall(r'\b\w+\b', text.lower())
# 使用 Counter 来计数每个单词出现的次数
word_count = Counter(words)
return dict(word_count)
# 测试函数
text = """Hello world!
This is an example.
Word count is fun.
Is it fun to count words?
Yes, it is fun!"""
print(wordcount(text))
任务2:请使用本地vscode连接远程开发机,将上面你写的wordcount函数在开发机上进行debug,体验debug的全流程,并完成一份debug笔记(需要截图)。
一步步调试即可