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')