django数据库导出命令dumpdata导出的json文件默认编码为ascii,如果数据中含有中文将会出现乱码。解决方法:
# 修改文件编码为utf8,传入要修改的文件对象和编码后文件的存储路径
def change_file_encode_to_utf8(file_path, encoded_file_path):
open(encoded_file_path, "wb").write(open(file_path, "rb")
.read().decode("unicode_escape").encode("utf8"))