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'的更多相关文章

  1. Django项目与mysql交互进行数据迁移时报错:AttributeError: 'str' object has no attribute 'decode'

    问题描述 Django项目启动,当我们执行命令 python manage.py makemigrations 出现如下错误: File , in last_executed_query query ...

  2. Django2.2报错 AttributeError: 'str' object has no attribute 'decode'

    准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: AttributeError: 'str' object has ...

  3. 解决编码问题:AttributeError: 'str' object has no attribute 'decode'

    1. 问题发现: 出现:读取文件,对其进行解码,出现错误,AttributeError: 'str' object has no attribute 'decode' 解释:属性错误,str对象不包含 ...

  4. AttributeError: 'str' object has no attribute 'decode'

    ue = e.decode('latin-1')修改为: ue = e.encode('ascii', 'strict')

  5. 执行: python manage.py makemigrations报AttributeError: 'str' object has no attribute 'decode'

    找到错误代码(line146):query = query.encode(errors='replace') 解决方法:把decode改为encode即可.

  6. Django 运行报异常:AttributeError: 'str' object has no attribute 'get'

    Technorati Tags: Python,Django,Web 在使用django.contrib.auth用户机制进行用户的验证.登录.注销操作时,遇到这个异常. 首先是写了一个登录的视图,要 ...

  7. Python PyInstaller 打包报错:AttributeError: 'str' object has no attribute 'items'

    pyinstaller打包时报错:AttributeError: 'str' object has no attribute 'items' 网上查询,可能是setuptools比较老: 更新一下 p ...

  8. 【Python-遇到的Error】AttributeError: 'str' object has no attribute 'input_text'

    学习类的实例化的时候遇到了AttributeError: 'str' object has no attribute 'input_text', 以下是报错的代码及修改正确的代码. class shu ...

  9. python2 'str' object has no attribute 'decode'

    '.decode('hex') 上述代码,报错: 'str' object has no attribute 'decode' 查找原因: https://stackoverflow.com/ques ...

随机推荐

  1. asp.net开发微信公众平台----目录汇总-持续更新

    1.[c#]asp.net微信公众平台开发(1)数据库设计 2.[c#]asp.net微信公众平台开发(2)多层架构框架搭建和入口实现 3.[c#]asp.net微信公众平台开发(3)微信消息封装及反 ...

  2. Jmeter 上传下载文件

    最近很多同学都在问jmeter上传.下载文件的脚本怎么做,要压测上传.下载文件的功能,脚本怎么做,网上查了都说的很含糊,这次呢,咱们就好好的把jmeter的上传下载文件好好缕缕,都整明白了,怎么个过程 ...

  3. crfclust.bdb导致磁盘满

    检查ora.crf服务 crsctl stat res ora.crf -init -t 关闭ora.crf服务 crsctl stop res ora.crf -init cd $ORACLE_HO ...

  4. MATLAB 用 imresize() 函数缩小图象是 double 和 uint8 有差别

    今天发现一个奇怪的现象. 在用 imresize() 缩小图象时,如果图象时 double 格式的,缩小后会产生不连通的现象. 下面是原图: 对这张图象 img 做 simg = imresize(i ...

  5. 解决Win7部分便笺的元数据已被损坏的方法

    Win7部分便笺的元数据已被损坏的方法 我们使用键盘上"Win+F"组合键搜索功能,直接找到"inkobj.dll"这个文件,一般会搜索出来好多,先随便选一个. ...

  6. 远程操作 SQl server2008新建角色和数据库

    远程操作 SQl server2008 1.windows身份登录,安全性-->登录名(右键)-->新建登录名:yc ,密码111111-->点选sql server身份验证--&g ...

  7. css圣杯布局

    HTML <div class="container"> <div class="content">content</div> ...

  8. ScoutSuite:一款针对云集群环境的安全审计工具

    工具介绍 Scout Suite是一款针对云集群环境的开源安全审计工具,主要针对的是云端环境的安全状况.通过使用云服务提供商暴露的API,Scout Suite可以从高安全风险区域收集配置数据以备研究 ...

  9. Spring cloud学习--Zuul01

    Zuul解决的问题 作为系统的统一入口,屏蔽了系统内部各个微服务的细节 可以与微服务治理框架结合,实现自动化的服务实例维护以及负载均衡的路由转发 实现接口权限校验与微服务业务逻辑的解耦 搭建Zuul服 ...

  10. php上传文件如何保证上传文件不被改变或者乱码

    很多网站上传文件都截取文件后缀,前面用时间错加后缀组成,然而一下下载的网站并不需要这样,需要保持原来的文件名,这里讲述一下 //上传操作 function uploadify(){ //var_dum ...