Python 将字典与代码分离

在当前项目下新建一个文件夹,把字典的json文件放入其中,比如你的json文件叫a.json

def load_config():
	with open(os.path.dirname(os.path.abspath(__file__))+"/config/a.json".format(sys.path[0]), "rb") as f:
		print("Load default config")
		return json.load(f)
temp = load_config()

猜你喜欢

转载自blog.csdn.net/lidongxx/article/details/89149989