Python sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings......
2016-03-31 18:45
661 查看
完整的错误信息如下:
You must not use 8-bit bytestrings unless you use a text _factory that can interpret 8-bit bytestrings (like text_factory = str).
It is highly recomme nded that you instead just switch your application to Unicode strings.
原因:
使用sqlite3数据库,对数据库进行操作的过程中,使用没有经过unicode解码的中文数据导致的。
举例:
category = Category.query.filter( Category.name == "上衣").first()
会报上述错误。
解决方案:
需要对中文进行unicode解码:
category = Category.query.filter( Category.name == u"上衣").first()
作者:yaoelvon@gmail.com
时间:2016/03/31
You must not use 8-bit bytestrings unless you use a text _factory that can interpret 8-bit bytestrings (like text_factory = str).
It is highly recomme nded that you instead just switch your application to Unicode strings.
原因:
使用sqlite3数据库,对数据库进行操作的过程中,使用没有经过unicode解码的中文数据导致的。
举例:
category = Category.query.filter( Category.name == "上衣").first()
会报上述错误。
解决方案:
需要对中文进行unicode解码:
category = Category.query.filter( Category.name == u"上衣").first()
作者:yaoelvon@gmail.com
时间:2016/03/31
相关文章推荐
- Python 2.7 学习笔记 访问mysql数据库
- Python debug —— invalid literal for int() with base 10
- PYTHON-进阶-编码处理小结
- python中的for i in range
- Ubuntu下安装numpy and matplotlib
- python基础练习(一)——自定义函数,数学运算,命令行输入
- Python + wGet 合璧,一键下载网页上所有的PDF
- Python3.5入门学习记录-列表、元组、字典
- Python学习笔记 - 使用APScheduler管理定时任务
- windows下面安装Python和pip终极教程
- python 关于tuple的一些小笔记
- Python any函数
- pycharm 找不到库的路径问题
- python安装包方法失效或缺失问题
- 对python 函数的一些理解
- python学习过程一
- python 文件流
- python关于list的一些小笔记
- 文章标题
- python 正则匹配电话与ip