入门岛
1. Linux基础知识
2. Python 基础知识
from collections import Counter
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: str):
text = text.lower().replace('.', '').replace(',', '').replace('\n', ' ')
words = [word[:-2] if word.endswith("'s") else word for word in text.split(' ') if word]
return dict(Counter(words))
if __name__ == '__main__':
res = wordcount(text)
print(res)