json写入支持中文字符

json写入支持中文字符
This commit is contained in:
xldistance 2019-05-13 11:57:13 +08:00 committed by GitHub
parent d1ac0379c6
commit b1a2f45484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,8 +97,8 @@ def save_json(filename: str, data: dict):
Save data into json file in temp path.
"""
filepath = get_file_path(filename)
with open(filepath, mode='w+') as f:
json.dump(data, f, indent=4)
with open(filepath, mode='w+',encoding = 'UTF-8') as f:
json.dump(data, f,sort_keys=True,indent =4,ensure_ascii=False)
def round_to(value: float, target: float):