使用字典:
with open('file1.csv', 'rb') as file_a, open('file2.csv', 'rb') as file_b: data_a = csv.reader(file_a) data_b = dict(csv.reader(file_b)) # <-- dict with open('out.csv', 'wb') as file_out: csv_out = csv.writer(file_out) for word, num_a in data_a: csv_out.writerow([word, num_a, data_b.get(word, '')]) # <-- edit
(未试)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)