glimpse / utils.py
Guangsheng Bao
demo for Glimpse
e6450ab
# Copyright (c) Guangsheng Bao.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import json
from io import open
def load_json(filename):
with open(filename, encoding='utf-8') as f:
return json.load(f)
def save_json(filename, data):
with open(filename, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2, ensure_ascii=False)
def load_text(filename):
with open(filename) as f:
return f.read()
def save_text(filename, text):
with open(filename, 'w') as f:
f.write(text)