被处理文件 test.txt:
with open('test.txt') as f:
while True:
line = f.readline()
39.555
if not line:
116.25
break
print(line)
去掉经纬度:
OutputFilename = 'cntraceOutput.log'
InputFilename = 'test.txt'
with open(OutputFilename, 'w') as file_object:
with open(InputFilename) as f:
while True:
line = f.readline()
if not line:
break
if str.find(line, '116.') != -1:
continue
if str.find(line, '39.') != -1:
continue
#line = line.replace('116.', "*****")
#line = line.replace('39.', "*****")
file_object.write(line)
导出带有关键字trace:
OutputFilename = 'output.log'
InputFilename = 'test.txt'
with open(OutputFilename, 'w') as file_object:
with open(InputFilename) as f:
while True:
line = f.readline()
if not line:
break
if str.find(line, 'upload:') != -1:
file_object.write(line)