读取yaml中的内容
def read_yml(path):
"""
读取yml文件中的数据
:param path: 文件yaml 的路径
:return: 返回读取yaml文件内的结果
"""
try:
file = os.path.isfile(path) #判断文件是否存在
if file:
files = os.path.splitext(path)
filename, suffix = files #获取文件后缀
if suffix == '.yml' or suffix == '.yaml':
with open(path, "r") as f:
yml = yaml.load(f, Loader=yaml.FullLoader)
return yml
else:
raise Exception('后缀写错了!')
else:
raise Exception("文件不存在!")
except Exception as e:
print(e)
窈窕包包,君子好逑