zoukankan      html  css  js  c++  java
  • 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
    然后就好了,问题解决!

  • 相关阅读:
    自建mail服务器之一:dns解析
    区间树
    3d tech
    3d
    平板比较
    Node。js 访问gmail
    node nightmare 网页自动化测试 sample
    node start
    中國駐香港外交部
    create a simple COM object
  • 原文地址:https://www.cnblogs.com/qqq789001/p/15703856.html
Copyright © 2011-2022 走看看