Advertisement
182days

File Search

May 3rd, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. #searches a text file for a keyword and prints the lines that match.
  2. searchfile = open("alice.txt", "r")
  3. for line in searchfile:
  4.     if " left " in line:
  5.         print (line)
  6. searchfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement