import csv
with open("t1.csv", "rb") as f:
reader = csv.reader(f)
with open("t2.csv", "rb") as e:
reader2 = csv.reader(e)
with open("alnew.csv", "wb") as cr:
writer = csv.writer(cr)
for row in reader:
print row + ["XXXXX"]
for row2 in reader2:
print row2 + ["OOOOO"]
if row[0] == row2[3]:
new = row + row2
writer.writerow(new)
第二个 for 循环不应该在每次通过第一个循环时迭代吗?它似乎只在第一次通过循环时运行。