Answers for "how to search text in text file by python"

7

how to check for a particular word in a text file using python

file = open("search.txt")
    print(file.read())
    search_word = input("enter a word you want to search in file: ")
    if(search_word in file.read()):
        print("word found")
    else:
        print("word not found")
Posted by: Guest on August-10-2020
6

python read text file look for string

f = open(filename,  "r")
   whattoReturn = "None"
   if strToFind in f.read():
      whattoReturn = strToFind
Posted by: Guest on April-01-2020

Code answers related to "how to search text in text file by python"

Python Answers by Framework

Browse Popular Code Answers by Language