I have a text file with message where it started with 'START' line and ends with 'END' line. I want the python code to read lines between these two words. I have a code which is reading lines between these two words. but it is also reading 'START' and 'End' lines. i want only lines between these two words.
i have tried this code which is also reading 'START' and 'END' words.
data=[]
flag=False
with open('/tmp/test.txt','r') as f:
for line in f:
if line.startswith('START'):
flag=True
if flag:
data.append(line)
if line.strip().endswith('END'):
flag=False
print ''.join(data)
please suggest the code which will read between two words excluding 'START' and 'END' lines
test.txt? - DirtyBit