远程连接ssh
python实现worldcount
import string
def wordcount(text):
# 移除文本中的标点符号
translator = str.maketrans('', '', string.punctuation)
cleaned_text = text.translate(translator).lower()
# 分割文本为单词列表
words = cleaned_text.split()
# 使用字典统计每个单词出现的次数
word_count = {}
for word in words:
if word in word_count:
word_count[word] += 1
else:
word_count[word] = 1
return word_count
# 测试函数
text = """
Got this panda plush toy for my daughter's birthday,
who loves it and takes it everywhere. It's soft and
super cute, and its face has a friendly look. It's
a bit small for what I paid though. I think there
might be other options that are bigger for the
same price. It arrived a day earlier than expected,
so I got to play with it myself before I gave it
to her.
"""
print(wordcount(text))
设置断点
debug后查看变量
运行到下一个断点