python 读取yaml文件
如建立conf_fat.yml文件,内容:
host:
doname: demo.pab.com.cn
port : 80
创建py_yaml.py文件,内容:
import yaml
with open("conf_fat.yml", "r") as file:
content = file.read()
data = yaml.load(content,Loader=yaml.FullLoader)
print(data['host']['doname'],data['host']['port'])
运行结果: