我有一個名爲鷹這樣與列表元素匹配的元組元素
eagles= [("NCMS000","NCMS000"),("NCFP000","NCFP000"),("NCMS00D","NCMS00D"),("NCCS000","NCCS000"),("NCCP000","NCCP000"),("NCMN000","NCMN000"),("NCFN000","NCFN000"),("NP000G0","NP000G0"),("NP000G0","NP000G0"),...
元組列表和一個名爲結果這樣的名單:
['"', '"', 'Fe', '1']
['Hola', 'hola', 'I', '1']
['como', 'como', 'CS', '0.999289']
['estas', 'este', 'DD0FP0', '0.97043']
['Bien', 'bien', 'NP00000', '1']
['gracias', 'gracia', 'NCFP000', '1']
['y', 'y', 'CC', '0.999962']
['tu', 'tu', 'DP2CSS', '1']
['yo', 'yo', 'PP1CSN00', '1']
['estoy', 'estar', 'VAIP1S0', '1']
['bien', 'bien', 'RG', '0.902728']
['huevo', 'huevo', 'NCMS000', '0.916667']
['calcio', 'calcio', 'NCMS000', '1']
['leche', 'leche', 'NCFS000', '1']
['proteina', 'proteina', 'NCFS000', '1']
['Francisco', 'francisco', 'NP00000', '1']
['1999', '1999', 'Z', '1']
['"', '"', 'Fe', '1']
我需要創建一個功能比較第3項結果列表與老鷹第1項中的一種連續循環。如果他們匹配,我需要返回一個列表的列表瓦特/ 4組的元素,如:
r = [['leche', 'leche', 'NCFS000', '1'],['proteina', 'proteina', 'NCFS000', '1'],['Francisco', 'francisco', 'NP00000', '1']]
我做了什麼至今:
def check(lst):
return [x[2] for x in lst if (x[2] in y[0] for y in eagles)]
IndexError: list index out of range.
我甚至無法提取從3元列表,並把它放在一個空
e = [x[0] for x in eagles]
r = [item for item in e if item in Result]
rg =[]
for i in Result:
rg = i[2]
同樣的錯誤
我能做些什麼?任何建議表示讚賞。
縱觀所有的答案和響應,我覺得你的數據的壞;我的猜測是[2]訪問多個答案。 – GoingTharn 2013-04-23 23:54:00