django项目过程中manage.py出现的 AttributeError: ‘str‘ object has no attribute ‘decode‘报错


 

1.问题

报错代码:AttributeError: 'str' object has no attribute 'decode'

报错截图:

2.上网搜索

参考网上大神给出的解释:

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

一般是因为str的类型本身不是bytes,所以不能解码

Python3的str 默认不是bytes,所以不能decode,只能先encode转为bytes,再decode

python2的str 默认是bytes,所以能decode

3.解决办法

那很显然我们只需要在出问题的代码之前转换一下就好了

找到报错代码

 

 修改解决问题

 最后成功运行