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.
"""
import re
def wordcount(text):
text = text.lower()
text = re.sub(r'[^\w\s]', '', text)
words = text.split()
word_dict = {}
for word in words:
word_dict[word] = word_dict.get(word, 0) + 1
return word_dict
print(wordcount(text))
InternLM_Task1.2
最新推荐文章于 2024-10-02 10:53:34 发布