大佬教程收集整理的这篇文章主要介绍了UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 107654: invalid start byte Django database change to MySQL,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我最近尝试将我的 Django 项目中的数据库从默认的 sqlite 切换到 MysqL。 相应地设置 MysqL 后,我使用了以下命令:
python manage.py dumPDAta > datadump.Json
# to export exisTing data into a Json file
在 setTings.py 中设置 MysqL 数据库并完成所有迁移后,尝试使用以下命令将 Json 文件加载到数据库:
python manage.py loaddata datadump.Json
# should return sth like "Installed 59 object(s) from 1 fixture(s)"
我收到以下错误:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 107654: invalID start byte
现在我尝试将 MysqL 数据库的默认字符集设置为 utf8,但没有任何反应。
当我在Pycharm中点击datadump.Json
文件时,我也收到如下警告,不知道是否相关:
file was loaded with the wrong enCoding: UTF-8
任何帮助将不胜感激
已解决: 我使用 Pycharm 的接口重新加载了带有 UTF-8 编码的 datadump.json 文件(打开文件时应该会在顶部提示您更改它)。 我还在文件中的某个地方有一个未闭合的括号,修复这两件事后一切正常。
以上是大佬教程为你收集整理的UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 107654: invalid start byte Django database change to MySQL全部内容,希望文章能够帮你解决UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 107654: invalid start byte Django database change to MySQL所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。