Python&django系列(亲测有效):Django2.2报错——AttributeError: ‘‘str‘‘ object has no attribute ‘‘decode‘‘

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




操作

准备将 Django 连接到 MySQL,在命令行输入命令

python manage.py makemigrations 

输入命令后报错:

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

python 3中只有unicode str,所以把decode方法去掉了。你的代码中,f1已经是unicode str了,不用decode

如果文件内容不是unicode编码的,要先以二进制方式打开,读入比特流,再解码。

方法说明

<
posted @   坦笑&&life  阅读(17)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示