python读取csv文件是报错_csv.Error: iterator should return strings, not bytes (did you open the file in text
来源:互联网 发布:淘宝 海外 上传身份证 编辑:程序博客网 时间:2024/06/06 15:03
python 读取csv文件报错问题
import csvwith open('E:/Selenium2script/DDT模块/test.csv','rb') as f: readers = csv.reader(f) next(readers,None) for line in readers: print(line)
输出:
_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
问题分析:因为此csv文件是一个文本文件,并非二进制文件。
解决:
import csvwith 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=' ',写入的数据不会空行。
阅读全文
1 0
- python读取csv文件是报错_csv.Error: iterator should return strings, not bytes (did you open the file in text
- csv.Error: iterator should return strings, not bytes
- Python csv模块读文件错误 _csv.Error: new-line character seen in unquoted field
- 关于python csv文件打开错误:_csv.Error: line contains NULL byte
- "The file you are trying to open, '[filename]', is in a different format" Excel Error
- Error: 'The service did not respond in a timely fashion'
- emulator: ERROR: You did not provide the name of an Android Virtual Device
- VNX5700_DR An error occurred during the login process. The storage processors did not log in proper
- Modules you should know in Python Libray
- Python-读取csv文件
- python读取CSV文件
- python 读取CSV 文件
- Python读取CSV文件
- Python读取CSV文件
- python读取csv文件
- python 读取csv文件
- python读取csv文件
- python读取csv文件
- 5.10 面向抽象编程(略)
- linux的基本命令
- FreeRtos 文件结构
- 指针的基本用法
- 浅谈define与inline的区别及程序说明
- python读取csv文件是报错_csv.Error: iterator should return strings, not bytes (did you open the file in text
- 5.11 开-闭原子(略)
- 【SpringMVC】适配器
- C语言操作符简单介绍
- 7.0新特性新1
- 小算法-快速幂
- 5.12 应用举例(略)
- QT android开发中QMainWindow的背景图片设置
- 空格替换 请编写一个方法,将字符串中的空格全部替换为“%20”。假定该字符串有足够的空间存放新增的字符,并且知道字符串的真实长度(小于等于1000),同时保证字符串由大小写的英文字母组成。 给定一