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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -