# -*- coding: utf-8 -*-
"""
@author:zhaiht
@file: yamlUtil.py
@time: 2020/8/4 14:12
@desc: analysis yaml
"""
import yaml
class loadYaml:
def read_yaml(self, filepath):
try:
return yaml.load(open(filepath, 'r', encoding='utf-8'), Loader=yaml)
except Exception as es:
print(F'读取{filepath}文件出错,错误是{es}')
return False
def write_yaml(self, filepath, data, mode='w'):
try:
with open(filepath, mode, encoding='utf-8') as f:
yaml.dump(data, f)
return True
except Exception as es:
print(F'内容:{data}\n写入{filepath}文件出错,错误是{es}')
return False
ly = loadYaml()