csv文件的读写
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import csv #读取csv文件 csv_file = csv.reader(open('F:/csv/XXXXXX.csv')) print(csv_file) """ #输出csv中的内容 for item in csv_file: print(item) """ #创建csv文件并写入 out = open('F:/csv/out.csv','a', newline = '') #'a'代表允许在现有数据上进行读写 csv_write = csv.writer(out, dialect = 'excel') #编程风格默认为excel格式,即用逗号分隔. for item in csv_file: csv_write.writerow(item) print('write over')#用缩进来控制是否为其循环体
新战场:https://blog.csdn.net/Stephen___Qin