I was searching on the internet but without any conclusion. I don´t know how to open file, find word open and then go one line under line with open and print the line. Here is my code, but i think it´s totally wrong:
def wstart(self, event):
pnfl = codecs.open("Save/savegame.txt", "r")
txtline = pnfl.readline()
while txtline <> "open":
txtline = pnfl.readline()
txtline = pnfl.readline()
print txtline
pnfl.close()
Please help somebody i really don´t know how to fix it!
This is one way to open and read a file:
with open("your.txt",'r') as f:
for line in f:
if "open" in line:
print f.next() # print the line after the line with open in it