Difficult-Rocket/libs/loads.py

19 lines
372 B
Python
Raw Normal View History

2020-12-05 21:24:54 +08:00
"""
writen by shenjackyuanjie
mail: 3695888@qq.com
"""
import json
def config(file_name, stack=None):
rd = {} # rd -> return
try:
with open(file_name, "r") as jf: # jf -> json file
rd = json.load(jf)
except FileNotFoundError:
2021-01-09 22:05:43 +08:00
raise FileNotFoundError("no config file")
2020-12-05 21:24:54 +08:00
if stack != None:
rd = rd[stack]
return rd