一、wordacount函数
def wordcount(text):
# 去除标点符号
punctuation = "!.,'?"
for p in punctuation:
text = text.replace(p, '')
# 转换为小写并分割单词
words = text.lower().split()
# 统计单词
return dict(Counter(words))
print(wordcount(text))
二、VScode连接InternStudio debug笔记
(1)VScode与InternStudio 的SSH连接
(2)创建wordcount.py文件,conda activate cheny激活之前创建的环境
(3)下载python debugger扩展,然后右上角选择python Debugger:debug Python File,然后在如图所示的地方设置断点进行调试
(4)调试过程如图所示
(5)最后运行结果如下