I ve been trying to nut out an issue when looping in python 3. When returning from sub routine the "line" variable has not incremented.
How do I get the script to return the latest readline from the subsroutine?
简称
def getData(line):
#print(line)
#while line in sTSDP_data:
while "/service/content/test" not in line:
line = sTSDP_data.readline()
import os, sys
sFileTSDP = "d:/ess/redo/Test.log"
sTSDP_data = open(sFileTSDP, "r")
for line in sTSDP_data:
if "MOBITV" in line:
getData(line) #call sub routine
print(line)
I m stepping through a large file and on a certain string I need to call a sub routine to process the next 5 (or 100) lines of data. When the sub routine completes and returns to the main program, it would be better to have it continue on from the last readline in the sub routine, not the last readline in the main program.
Daan s answer did the trick.