如建立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'])
运行结果:
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/276567.html