解决python :“ProgrammingError: You must not use 8-bit bytestrings unless you...”
来源:互联网 发布:ios js交互 编辑:程序博客网 时间:2024/06/06 07:06
1. 问题描述:
ProgrammingError: 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 recommended that you instead just switch your application to Unicode strings
2. 解决方法
2.1按提示修正
按照提示加入一下语句:
text_factory = str
但是如果字符中出现非ascii字符,那么依然不能解决问题,这样可以参考 2.2
2.2 把字符转化为unicode格式
比如把字符串str_name 转为unicode格式:
unicode( str_name )
这种方法有时会出现:“UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128 ...” 这种问题。
解决方法:
import sysreload(sys)sys.setdefaultencoding('utf8')
3. 参考文献
[1] http://www.byywee.com/page/M0/S467/467402.html
[2] http://blog.csdn.net/mindmb/article/details/7898528
0 0
- 解决python :“ProgrammingError: You must not use 8-bit bytestrings unless you...”
- Python报错:ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can
- Python报错:ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that ca
- Python:You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit byt
- [Python]sqlite3二进制文件存储问题(BLOB)(You must not use 8-bit bytestrings unless you use a text_factory...)
- Kill -9 Why You Should Not Use It Unless Absolutely Necessary
- iOS--错误集锦--'...' does not contain bit code. You must rebuild it with bit code enabled ...
- Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named
- 10 Places You Must Use Ajax
- Xcode7(修改Bitcode) does not contain bitcode. You must rebuild it with bit code enabled. -- @ShinePug
- Error “You must not call setTag() on a view Glide is targeting” when use Glide
- you are not authorized to use service
- SVN提交问题 You must use a JIRA no. as
- Window10 + tensorflow 安装(解决Error importing tensorflow, unless you are using bazel...)
- you must specify a host type if you use `--no-verify'
- xargs: unmatched double quote; by default quotes are special to xargs unless you use the -0 option
- YOU MUST BE PREPARED
- You Must Learn JavaScript
- Android4.2自定义升级包
- LUA io.input,io.output,io.write,io.read之间的关系
- Android R文件不能自动生成
- 苹果是大赢家!各种版本iPad均是续航神器
- 开发框架——横版格斗——3.碰撞检测
- 解决python :“ProgrammingError: You must not use 8-bit bytestrings unless you...”
- 查看手机内存
- equals()方法和==号的区别带来的问题
- hibernate 分组查询
- Parse转换和Convert转换有什么区别
- c 语言结束符标志(转)
- 强势领导力-3-特征
- 开发框架——横版格斗——4.技能的输入与检测
- 沙漠死神攻略