word="I'm a boby, I'm a girl. When it is true, it is ture. thit are cats, the red is red."
word=word.replace(',','').replace('.','')
word=word.split()
print(word)
setword=set(word)
for i in setword:
count=word.count(i)
print(i,'出现次数:',count)
["I'm", 'a', 'boby', "I'm", 'a', 'girl', 'When', 'it', 'is', 'true', 'it', 'is', 'ture', 'thit', 'are', 'cats', 'the', 'red', 'is', 'red']
true 出现次数: 1
cats 出现次数: 1
boby 出现次数: 1
ture 出现次数: 1
the 出现次数: 1
it 出现次数: 2
thit 出现次数: 1
When 出现次数: 1
are 出现次数: 1
a 出现次数: 2
girl 出现次数: 1
red 出现次数: 2
I'm 出现次数: 2
is 出现次数: 3