行,以便有一個輸入文件腳本像如下:使用Python來提取包含不同的關鍵字進入詞典
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)
任何幫助都將是非常美妙。
-1因爲你不知道True和'True'之間的不同, –