Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
736B

  1. # encoding:utf-8
  2. import json
  3. import os
  4. from common.log import logger
  5. config = {}
  6. def load_config():
  7. global config
  8. config_path = "config.json"
  9. try:
  10. if not os.path.exists(config_path):
  11. logger.error('配置文件路径不存在')
  12. return
  13. config_str = read_file(config_path)
  14. # 将json字符串反序列化为dict类型
  15. config = json.loads(config_str)
  16. logger.info("[INIT] load config: {}".format(config))
  17. except Exception as e:
  18. logger.error(e)
  19. def get_root():
  20. return os.path.dirname(os.path.abspath( __file__ ))
  21. def read_file(path):
  22. with open(path, mode='r', encoding='utf-8') as f:
  23. return f.read()
  24. def conf():
  25. return config