So I am trying to find a string from a file. My code looks like this:
fname=open('results', 'r')
lines=fname.readlines()
for i in lines:
print i
s=lines[41]
x= "0x80000680: 0x00000000\n"
if (i == x) :
stuff happens
My code reads the file just finds the line. that matches 'x' but it does not go into the if statement. A thing a noticed that when it prints out the line in the output it seems to have more spaces, but when looking at the variable it self it only has one. I have tried to put in the same amount of spaces for both results, but I am still not able to go into the if statement. Here is the output of 'i' when I print it when it gets to that line:
0x80000680: 0x00000000
and it appears as :
str: 0x80000680: 0x00000000\n
when I look at the variables. If I look at x in the variables it shows str: 0x80000680: 0x00000000\n
print repr(i). My best guess would be that the actual line in question is"0x80000680:\t0x00000000\n"or something similar.ifthat means it isn't the same line asx. You could consider using regex (though it may be overkill) to only match the parts of the line you want.print repr(i)should show you exactly what to use on your linex = ....