解决python 保存json到文件时 中文显示16进制编码的问题
发布时间:2020-12-20 11:00:58 所属栏目:Python 来源:网络整理
导读:python 2.7 import codecsimport jsonwith codecs.open('Options.json','w',encoding='utf-8') as f: json.dump(_data,f,ensure_ascii=False,indent=4,encoding='utf-8') codecs python官方文档中文翻译 使用给定模式打开编码文件,并返回提供透明编码/解码
python 2.7import codecs import json with codecs.open('Options.json','w',encoding='utf-8') as f: json.dump(_data,f,ensure_ascii=False,indent=4,encoding='utf-8')
python 3import json with open('Option.json',encoding='utf-8') as f: json.dump(data,encoding='utf-8')
Option.json{ "default": "中文","field": "_display_name","type": "str","len": "255","not_null": "True" } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |