(Mac)安装pip

sudo easy_install pip

通过pip安装yaml模块

pip3 install pyyaml

读取yaml

#yaml文件
project: test
name: chenchaung'
createdBy: chen
copyright: 2017年 chen

python方法:

import yaml

f = open('config.yaml', encoding='utf-8')
dic = yaml.load(f)
print(dic)

读取结果是个字典类型:

{'project': 'test', 'name': "chenchaung'", 'createdBy': 'chen', 'copyright': '2017年 chen'}