2 回答
TA贡献1735条经验 获得超5个赞
假设输入文件中的每个条目都采用以下格式...
[{TYPE}] Timeout after {miliseconds} millis, source ref: {random-number}...
lst = open("result.txt").readlines()
pretoken = "["
posttoken = "]"
foundTypes = []
log = []
for line in lst:
foundType = ""
for letter in line:
if letter == pretoken: pass
elif letter == posttoken: break
else: foundType += letter
if foundType not in foundTypes:
foundTypes.append(foundType)
log.append(line)
print(log)
TA贡献1827条经验 获得超7个赞
您只需要逐行打开并读取日志文件。
a=b=None
with open('result.txt') as infile:
if a == None:
a = infile.readline()
b = infile.readline()
while a:
a = infile.readline()
print('proc similar(a,b)')
b = a
添加回答
举报