12345678910111213141516171819202122 |
- import yaml
- def read_yaml(path='application.yaml'):
- try:
- with open(path, 'r') as file:
- data = file.read()
- # result = yaml.load(data)
- result = yaml.load(data, Loader=yaml.FullLoader)
- return result
- except Exception as e:
- print(e)
- return None
- def write_yaml(path='application.yaml', data=None):
- try:
- with open(path, 'w', encoding='utf-8') as f:
- yaml.dump(data=data, stream=f, allow_unicode=True)
- except Exception as e:
- print(e)
|