csv.Error: iterator should return strings, not bytes
来源:互联网 发布:怎样成为淘宝客挣钱 编辑:程序博客网 时间:2024/06/14 01:59
python 读取csv文件问题
with open("fer2013.csv", "rb", encoding="utf-8") as vsvfile: reader = csv.reader(vsvfile) rows = [row for row in reader] print(rows)
输出:
Error: iterator should return strings, not bytes (did you open the file in text mode?)
问题分析
因为此csv文件并非二进制文件, 只是一个文本文件。
问题解决
with open("fer2013.csv", "rt", encoding="utf-8") as vsvfile: reader = csv.reader(vsvfile) rows = [row for row in reader] print(rows)
或者
# 因为open()默认打开文本文件with open("fer2013.csv", "r", encoding="utf-8") as vsvfile: reader = csv.reader(vsvfile) rows = [row for row in reader] print(rows)
阅读全文
1 0
- csv.Error: iterator should return strings, not bytes
- python读取csv文件是报错_csv.Error: iterator should return strings, not bytes (did you open the file in text
- Error:a bytes-like object is required not str
- TypeError: unicode strings are not supported, please encode to bytes: 'hu'
- Environment error: "JAVA_HOME" should not be defined. 错误解决方法
- C++ Runtime Error :STL list "list iterator not incrementable"
- error C2533: ' ::{ctor}' : constructors not allowed a return type
- error C2533: 'CompositionWidget::{ctor}' : constructors not allowed a return type
- error C2533: ' ::{ctor}' : constructors not allowed a return type
- java mock when return can not resolve method xxxx error
- load_file:could not read 174863040 bytes from 'system.img' error:cannot load 'system.img'
- Error occurred initialization of VM Could not allocate metaspac:xxx bytes发生时
- Python 3.x Error:TypeError: a bytes-like object is required, not 'str'
- Strings, bytes, runes and characters in Go
- ??? Error using ==> nlinfit at 127 MODELFUN should return a vector of fitted values the same length
- Tomcat Run Error:NB: JAVA_HOME should point to a JDK not a JRE
- Error:NB:JAVA_HOME should point to a JDK not a JRE
- wireshark ERROR:capture_dlg.c:408:capture_filter_check_syntax_cb: code should not be reached
- SpringMVC源码(四)Controller控制器2-AbstractController
- 进度条
- Android第三方开源库:PopupWindow相关
- [LeetCode]69. Sqrt(x)
- 单例模式
- csv.Error: iterator should return strings, not bytes
- QtWidget: 自定义不规则窗体与按钮
- Android NavigationBar(菜单栏,导航栏)问题记录
- Java基础入门(四)选择结构
- HDOJ 1003Max Sum (dp)
- 解决Mysql中只能通过localhost登陆不能通过ip登陆的问题
- fragment下找不到getWindowManager() getLayoutInflater()方法
- ldconfig 创建连接名字
- Hash 函数的现状,2012