ATM-db-dnhandler

import os,json
from conf import settings


def select(name):
user_path = os.path.join(settings.BASE_DB,'%s.txt'%name)
if os.path.exists(user_path):
with open(user_path,'r',encoding='utf-8')as f:
dic = json.load(f)
return dic
else:
return None


def save(dic):
user_path = os.path.join(settings.BASE_DB,'%s.txt'%dic['name'])
with open(user_path,'w',encoding='utf-8')as f:
json.dump(dic,f,ensure_ascii=False)
f.flush()
原文地址:https://www.cnblogs.com/wangcheng9418/p/9221757.html