练习内容
词频统计,对一段字符串"python is a popular programming language. It is widely used for web development."
- 统计每个单词出现的次数
- 使用字典表示
- 区分大小写
词频统计,对一段字符串"python is a popular programming language. It is widely used for web development."
def word_statis(words):
word_list=words.split()
print(word_list)
words_count={}
for word in word_list:
words_count[word]=words.count(word)
return words_count
if __name__ == '__main__':
str1="python is a popular programming language. It is widely used for web development."
print(word_statis(str1))