1234567891011121314151617181920212223242526 |
- # -*- coding: utf-8 -*-
- # @Time : 2024/6/7
- # @Author : 魏志亮
- import yaml
- def yaml_conf(path, encoding='utf-8'):
- with open(path, 'r', encoding=encoding) as f:
- data = yaml.safe_load(f)
- return data
- def read_conf(dict_conf, col, default_value=None):
- if col in dict_conf:
- res = dict_conf[col]
- if res is None and default_value is not None:
- return default_value
- return res
- else:
- return default_value
- if __name__ == '__main__':
- from pprint import pprint
- pprint(yaml_conf("../../conf/db.yaml"))
|