我有以下代码:
included_cols = [1, 3, 5]
w = csv.writer(open(args.output,'w'))
with open('input.csv', 'r') as input_file:
fid = csv.reader(input_file, delimiter = ',')
for row in fid:
item = [row[i] for i in included_cols)]
w.writerows(item)
对于每次迭代,row
类似于[1, 2]
......[3, 4]
等等。但它并没有将每个列表写成一行w
......有什么想法可以解决这个问题吗?