我通过删除我已经解析过的行来实现我的想法,它运行得很好,但这只是我的一个愉快的例子,因为我不再需要我操作过的任何数据。
对于那些仍然需要它的人,我认为@tdelaney代码很好用,我感谢他的回答!在
我是这样做的:from __future__ import print_function
import os
import sys
initialCall = os.stat("test.txt").st_size
def AssembleTC(parameter):
print("CALLED PARAMETER = " + str(parameter))
if parameter == 0:
sys.exit()
else:
file = open("test.txt").read().splitlines()
for index, line in enumerate(file):
if file[index] == "@@@TC_FIN@@@":
fin = index;
print ("FIN POSITION = " + str(fin))
break
check = os.stat("test.txt").st_size
print("File size = " + str(check))
while check > 1:
for index, line in enumerate(file):
if "@@@ TC