0x01 错误原因
python manage.py makemigrations
报错提示: AttributeError: 'str' object has no attribute 'decode'
0x02 解决
直接定位到报错文件
C:\python38\Lib\site-packages\django\db\backends\mysql\operations.py
修改源码:
# 头部导入
from django.utils.encoding import force_text
# 报错的位置更改
query = getattr(cursor, '_executed', None)
# if query is not None:
# query = query.decode(errors='replace')
# return query
return force_text(query, errors='replace')
0则评论给“AttributeError: 'str' object has no attribute 'decode'”