我试图在 python 中运行这个程序,但它一直给我一个错误,即列表索引超出 if 语句行的范围。但它确实会在必须打印的地方打印出“找到的匹配项”。
import csv
with open('/Users/jadhav/Documents/Hubble files/m4_hubble_1.csv') as f:
bl = [[],[],[],[],[]]
reader = csv.reader(f)
for r in reader:
for c in range(5):
bl[c].append(r[c])
print "The files have now been sorted into lists"
for c in range(0,999):
if bl[4][c] == "HST_10775_64_ACS_WFC_F814W":
print "match found"
else:
del bl[0][c]
del bl[1][c]
del bl[2][c]
del bl[3][c]
del bl[4][c]