Python readlines string issue -
import os fname = "input1.txt" if os.path.isfile(fname): f = open("input1.txt", "r") row in f.readlines(): if "logging failed" in row: print "the file 'logging failed' in it" else: print "the file doesn\'t 'logging failed' in it"
my input1.txt
says logging failedtest how can make notice "test" should printout logging failed if text doesnt have additional characters?
edit: sorry bad english, meant is: if input1.txt has "logging failed", should print out 'file it'. if has other characters (for example 'logging faaaailed' or 'logging failed1', should print out 'it doesnt logging failed'. reads there logging failed , ignores other characters in input1.txt
maybe i'm missing something, why can't explicitly compare row string "logging failed" ?
eg. if row == "logging failed"
Comments
Post a Comment