Python实现wordcount
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.
"""
def wordcount(text):
text =text.replace("?","").replace(".","").replace(",","")
dict={}
for i in text.split():
i.lower()
if i in dict:
dict[i]+=1
else:
dict[i]=1
return dict
print(wordcount(text))
使用了字典,虽然replace效率会有点低下,不过简单
Vscode连接InternStudio debug笔记
可以在右下角切换python环境
打断点 逐步运行等...
debug的体验...和在本地一样?没感觉出和本地的区别