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'])


运行结果:

 

 



 

posted @ 2022-07-24 00:41  遇事不决,量子力学  阅读(137)  评论(0编辑  收藏  举报