I\'m writing a Python script. I need to search a text file for a word and then print part of that line. My problem is that the word will not be an exact match in the text fi
Here's one way - split each line by spaces, then search each part for "color=":
with open("textfile.txt") as openfile: for line in openfile: for part in line.split(): if "color=" in part: print part