AttributeError:
‘str’ object has no attribute ‘decode’’ 或’bytes’ object has no attribute 'encode’
启动Django项目时可能会报错其中一种
遇到’str’ object has no attribute ‘decode’’ ,
需要把query = query.decode(errors=‘replace’)中decode改为encode。
遇到’bytes’ object has no attribute ‘encode’,需要把encode改为decode。
如果同时启动两个项目有可能造成冲突,不能同时启动。
解决方法:
修改文件源码:
当前python解释器安装目录/site-packages/django/db/backends/mysql/operations.py
第146行
将:
if query is not None:
query = query.decode