1#get file object reference to the file
2file = open("C:\workspace\python\data.txt", "r")
3#read content of file to string
4data = file.read()
5#get number of occurrences of the substring in the string
6occurrences = data.count("python")
7print('Number of occurrences of the word :', occurrences)
1object reference to the file
2file = open("C:\workspace\python\data.txt", "r")
3#read content of file to string
4data = file.read()
5#get number of occurrences of the substring in the string
6occurrences = data.count("python")
7print('Number of occurrences of the word :', occurrences)