_csv.Error: iterator should return strings, not bytes (did you open the file
python 读取csv文件问题
with open (path,'rb') as csvfile:
reader=csv.reader(csvfile,delimiter=',',quotechar='"',doublequote=False)
for row in reader:
运行程序出现提示:
_csv.Error: iterator should return strings, not bytes (did you open the file
问题原因:因为此csv文件并非二进制文件, 只是一个文本文件。
修改代码
with open (path,'rt') as csvfile:
reader=csv.reader(csvfile,delimiter=',',quotechar='"',doublequote=False)
for row in reader:
问题解决