Answers for "python searching in a text file"

3

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
1

file searching in python

with open('largeFile', 'r') as inF:
    for line in inF:
        if 'myString' in line:
            # do_something
Posted by: Guest on September-06-2021

Code answers related to "python searching in a text file"

Python Answers by Framework

Browse Popular Code Answers by Language