我想统计一条英语字符串中,每个单词出现的次数。
如,我想统计
“I love python I love java I learn python”
这条字符串中的每个单词出现了几次,
方法如下:
# -*- coding: utf-8 -*-
'''
功能:统计字符串中各单词个数
作者: XxLyle
日期: 2021.11.25
'''
text = 'I Love python I Love java I Learn python'
words = text.split(' ')
diff_words