import csv with open('E:/Selenium2script/DDT模块/test.csv','rb') as f: readers = csv.reader(f) next(readers,None) for line in readers: print(line)
问题分析:因为此csv文件是一个文本文件,并非二进制文件。
解决:
import csv with open('E:/Selenium2script/DDT模块/test.csv','rt') as f: readers = csv.reader(f) next(readers,None) for line in readers: print(line)或者‘rt’换成‘r’
备注:此处的next语句为不读取标题key值
with open(file_name,'wt',newline='') as f:
加入newline=' ',写入的数据不会空行。