📌  相关文章
📜  用于计算文本文件中单词出现次数的 Python 程序 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:40.848000             🧑  作者: Mango

代码示例1
object reference to the file
file = open("C:\workspace\python\data.txt", "r")
#read content of file to string
data = file.read()
#get number of occurrences of the substring in the string
occurrences = data.count("python")
print('Number of occurrences of the word :', occurrences)