python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'
1、Python3.x和Python2.X版本有一些区别,我遇到了两个问题如下:
a.第一个报:mysqlclient 1.3版本不对:
解决办法:注释掉这行即可;
b.第二个报:字符集的问题:
报错如下:File "C:\Users\Administrator\PycharmProjects\untitled1\venv\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
报错截图:


python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'的更多相关文章
- Django项目与mysql交互进行数据迁移时报错:AttributeError: 'str' object has no attribute 'decode'
问题描述 Django项目启动,当我们执行命令 python manage.py makemigrations 出现如下错误: File , in last_executed_query query ...
- Django2.2报错 AttributeError: 'str' object has no attribute 'decode'
准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: AttributeError: 'str' object has ...
- 解决编码问题:AttributeError: 'str' object has no attribute 'decode'
1. 问题发现: 出现:读取文件,对其进行解码,出现错误,AttributeError: 'str' object has no attribute 'decode' 解释:属性错误,str对象不包含 ...
- AttributeError: 'str' object has no attribute 'decode'
ue = e.decode('latin-1')修改为: ue = e.encode('ascii', 'strict')
- 执行: python manage.py makemigrations报AttributeError: 'str' object has no attribute 'decode'
找到错误代码(line146):query = query.encode(errors='replace') 解决方法:把decode改为encode即可.
- Django 运行报异常:AttributeError: 'str' object has no attribute 'get'
Technorati Tags: Python,Django,Web 在使用django.contrib.auth用户机制进行用户的验证.登录.注销操作时,遇到这个异常. 首先是写了一个登录的视图,要 ...
- Python PyInstaller 打包报错:AttributeError: 'str' object has no attribute 'items'
pyinstaller打包时报错:AttributeError: 'str' object has no attribute 'items' 网上查询,可能是setuptools比较老: 更新一下 p ...
- 【Python-遇到的Error】AttributeError: 'str' object has no attribute 'input_text'
学习类的实例化的时候遇到了AttributeError: 'str' object has no attribute 'input_text', 以下是报错的代码及修改正确的代码. class shu ...
- python2 'str' object has no attribute 'decode'
'.decode('hex') 上述代码,报错: 'str' object has no attribute 'decode' 查找原因: https://stackoverflow.com/ques ...
随机推荐
- vue实现动态显示与隐藏底部导航的方法分析
本文实例讲述了vue实现动态显示与隐藏底部导航的方法.分享给大家供大家参考,具体如下: 在日常项目中,总有几个页面是要用到底部导航的,总有那么些个页面,是不需要底部导航的,这里列举一下页面底部导航的显 ...
- ''.startswith() and ''.endswith() instead of string slicing to check for prefixes or suffixes.
w http://legacy.python.org/dev/peps/pep-0008/ Yes: if foo.startswith('bar'):No: if foo[:3] == 'bar' ...
- 【ABAP系列】SAP ABAP模块-取整操作中CEIL和FLOOR用法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP模块-取整操作中 ...
- hash-散列笔记
散列基础与整数散列 散列(hash哈希)的基本思想--"将元素通过一个函数转换为整数,使该整数可以尽量唯一地代表这个元素".其中把这个转换函数称为散列函数H,元素在转换前为key, ...
- JS中设置input的type="radio"默认选中
html: <input id="Radio1" type="radio" value="男" name="st_Sex&q ...
- EasyUI的datagrid有值但是显示不出来
$("#goodsList").datagrid({ url: "../Ajax/GoodsAjax.ashx", queryParams: { cmd ...
- CentOS7通过SpeedTest工具测速
首先要安装SpeedTest工具,这里提供两种方法安装SpeedTest: 一.通过直接下载SpeedTest脚本,给权限运行脚本即可 [root@bogon ~]#wget -O speedtest ...
- 19、NumPy——线性代数
NumPy 线性代数 NumPy 提供了线性代数函数库 linalg,该库包含了线性代数所需的所有功能,可以看看下面的说明: 函数 描述 dot 两个数组的点积,即元素对应相乘. vdot 两个向量的 ...
- 使用jdbc查询防止出现中文乱码的方法
在使用mysql创建数据库及表格,在navicat中可以正常查询出中文,但使用jdbc查询的结果中,中文为乱码. 网上查到资料,为了能够彻底一劳永逸的解决这个问题,需要修改mysql下配置文件my.i ...
- 常用颜色的RGB分布
RGB色彩模式是工业界的一种颜色标准,它通过对红(RED).绿(GREEN).蓝(BLUE)三种基本颜色的相互组合从而叠加出各种颜色.RGB色彩模式为每一个红.绿.蓝分类了0-255范围内的亮度值. ...