From b1a2f45484ffc70132964187bc3cb1a7b7a85bbd Mon Sep 17 00:00:00 2001 From: xldistance <819873074@qq.com> Date: Mon, 13 May 2019 11:57:13 +0800 Subject: [PATCH] =?UTF-8?q?json=E5=86=99=E5=85=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit json写入支持中文字符 --- vnpy/trader/utility.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index f6c3dcdd..c25eaf73 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -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):