SQLAlchemy 报ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings错误python
python2.x中最讨厌的就是编码问题了,写下来以备后用。less
解决方法:ide
1.开头加上:编码
#encoding: utf-8
2.尝试把字符转化为unicode格式spa
unicode( str_name )
这种方法有时会出现:“UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128 ...” 这种问题。code
解决方法:orm
import sys reload(sys) sys.setdefaultencoding('utf8')