我的列表中有大量的文本數據,而且我的問題發現特定的值太慢。因爲我必須從列表中找到50個以上的關鍵字。使用線程在列表中查找特定值
這裏我的工作腳本:
for num, line in enumerate(MyList):
passList = []
if "pass" in line:
passList.append(line)
failedList = []
if "failed" in line:
failedlist.append(line)
doneList = []
if "done" in line:
doneList.append(line)
#..
#...
#....more and more conditions here
有沒有辦法有一個快速的執行,或者使用線程,如果沒有其他的解決方案。
任何建議/意見,在此先感謝..
你爲什麼不解析線和檢查,如果你正在尋找的字是在準確的位置?請顯示該行的格式。 – thefourtheye
你可以使用grep嗎?這當然更快。 – fiacre
@thefourtheye,我正在找到確切的值,現在我只是使用該虛擬字符串來查找,但實際上在我的if條件下它也在列表中。 –