文本文件
服务器配置文件
xxx.yaml
name:
xiaomu
age:
10
xingqing:
- haha
- heihei
new:
a: b
c: 1
pip install pyyaml
import yaml
f = open(yaml_file, 'r')
data = yaml.load(f.read())
f.close()
# coding:utf-8
import yaml
def read(path):
with open(path, 'r') as f:
data = f.read()
_result = yaml.load(data, Loader=yaml.FullLoader)
return _result
if __name__ == '__main__':
result = read('muke.yaml')
print(result, type(result))
print(dir(yaml))