You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RWUtils.py 450B

1 year ago
12345678910111213141516171819
  1. # -*- coding: utf-8 -*-
  2. from json import loads
  3. from ruamel.yaml import safe_load
  4. def getConfigs(path, read_type='yml'):
  5. with open(path, 'r', encoding="utf-8") as f:
  6. if read_type == 'json':
  7. return loads(f.read())
  8. if read_type == 'yml':
  9. return safe_load(f)
  10. raise Exception('路径: %s未获取配置信息' % path)
  11. def readFile(file, ty="rb"):
  12. with open(file, ty) as f:
  13. return f.read()