一、python实现Wordcount
import re
def clean_text(text):#文字清洗
cleaned_text = re.sub(r'[^\w\s]', '', text)
text1 = cleaned_text.lower()
return text1
def wordcount(text1):#单词计数
count_dict={}
words=text1.split()
for word in words:
if word in count_dict:
count_dict[word]+=1
else:
count_dict[word]=1
return count_dict
text="""Hello world!
This is an example.
Word count is fun.
Is it fun to count words?
Yes, it is fun !"""
text1=clean_text(text)
result = wordcount(text1)
print(result)
运行结果
二、VScode连接internlm,远程debug
1、创建一个launch.json 文件、选择python debug,
2、打断点,调试