所以有一个输入文件到脚本,如下所示:
20248109|Generic|1|xxx|2|yyy|LINEA|68.66|68.67|True|2920958141272
.
.
.
21248109|Generic|3|xxx|4|www|LINEB|7618|7622|True|2920958281071.97
希望python脚本遍历并将LINEA放入字典中,如下所示{{1:[68.66,68.67]},{3:[7618,7622]}}
据我所知,这是:
Key = ["LINEA", "LINEB"]
fin = open(path)
test = []
for line in fin.readlines():
if True in [item in line for item in Key]:
test.append(line)
任何帮助都会很棒。