YAML 是 “YAML Ain’t a Markup Language”(YAML 不是一种标记语言)的递归缩写。在开发的这种语言时,YAML 的意思其实是:”Yet Another Markup Language”(仍是一种标记语言)。
使用方法
import os
import yaml
def read_yaml(readPath):
"""readPath: yaml文件地址"""
with open(readPath, encoding='utf-8') as file:
data = yaml.safe_load(file)
return data
if __name__ == '__main__':
data = read_yaml(os.path.abspath(os.path.dirname(os.getcwd())) + '\\config\\config.yaml')
print(data)