🔍 Find Keywords Through a File

PHOTO EMBED

Mon Oct 24 2022 05:44:38 GMT+0000 (Coordinated Universal Time)

Saved by @L0uJ1rky45M #python

handler = open('textfile.txt')
for line in handler:
    if line.startswith('From:') : #State your criteria. For example, the line must start with "From:"
        print(line)
              
              
content_copyCOPY

We can put an "if statement" in the "for loop" to only print lines that meet some criteria

https://www.py4e.com/lessons/files#