import csv csvFile = open("G:\\test.csv",'w+') # +是可读写模式 try: writer = csv.writer(csvFile) writer.writerow(('number','number plus 2','number times 2')) # 将参数横向铺成一行 for i in range(10): writer.writerow((i,i+2,i*2)) finally: csvFile.close()