这是一个把最后一列重复一次的例子:
import csv
with open('test.csv') as csvfile: rows = csv.reader(csvfile) with open('test1.csv','w', newline='') as f: writer = csv.writer(f) for row in rows: row.append(row[len(row)-1]) writer.writerow(row)
Python是纯粹的自由软件, 源代码和解释器CPython遵循 GPL(GNU General Public License)协议[2] 。Python语法简洁清晰,特色之一是强制用空白符(white space)作为语句缩进。