首页 > 数据库技术 > 详细

SQLAlchemy解决ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory

时间:2014-10-06 14:38:40      阅读:483      评论:0      收藏:0      [点我收藏+]

SQLAlchemy 报ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings错误

python2.x中最讨厌的就是编码问题了,写下来以备后用。

解决方法:

1.开头加上:

#encoding:  utf-8


 2.尝试把字符转化为unicode格式

unicode( str_name )

这种方法有时会出现:“UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128 ...” 这种问题。

解决方法:

import sys
reload(sys)
sys.setdefaultencoding(‘utf8‘)


SQLAlchemy解决ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory

原文:http://xiaosu.blog.51cto.com/2914416/1560796

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!