Jan-09-2020, 01:27 AM
Hi, Folks! I'm trying to open a .txt file and find a line with a specific expression but the return isn't what I expected:
So, what i get is a lot of "Didn't find" but I know that there's this expression in the file. And, I noticed that if i ask for just one caracter, like "N" instead the "Net", the code returns lines with it.
1 2 3 4 5 6 7 8 9 10 11 |
f = open ( "file.txt" , "r" ) for line in f: if "Net" in line: print (line) else : print ( "Didn't find" ) f.close() |