This commit is contained in:
2022-06-30 22:19:59 +08:00
parent f424be4a1d
commit a579b5334e
9 changed files with 773 additions and 0 deletions

20
utils.py Normal file
View File

@@ -0,0 +1,20 @@
import json
def save_dict(path, json_dict, indent=4, mute=True):
if not mute:
print('dumping json string...')
text = json.dumps(json_dict, indent=indent, ensure_ascii=False)
if not mute:
print('saving to {0}...'.format(path))
with open(path, 'w+', encoding='utf-8') as f:
f.write(text)
def load_dict(path, mute=True):
if not mute:
print('reading file {0}...'.format(path))
with open(path, 'r', encoding='utf-8') as f:
text = f.read()
if not mute:
print('parsing json...')
json_dict = json.loads(text)
return json_dict