Django框架 python3.7+django2.2 报错:AttributeError: ‘str’ object has no attribute ‘decode’解决办法
作者:互联网
转载于:https://blog.csdn.net/qq_41630218/article/details/89631835?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2.highlightwordscore&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2.highlightwordscore
环境:python3.7+django2.2
报错信息:
AttributeError: ‘str’ object has no attribute ‘decode’
解决办法:
找到python文件下的django文件>db文件>backends>mysql>operations.py
打开文件:
打开后ctrl+f搜索query.decode
然后将query.decode改为query.encode
#原代码:
query = getattr(cursor, '_executed', None)
if query is not None:
query = query.decode(errors='replace')
return query
#修改为:
query = getattr(cursor, '_executed', None)
if query is not None:
query = query.encode(errors='replace')
return query
然后就好了,问题解决!
标签:blog,None,django2.2,no,decode,报错,文件,query 来源: https://www.cnblogs.com/qqq789001/p/15703856.html