处理yaml中的配置文件
confyaml的Python项目详细描述
会议
Python包来处理YAML中的配置文件
使用
fromconfyamlimportConfig# Assumes you have a file called config.yamlconfig=Config()# But you can also pass the path of other yaml fileother_config=Config("other_config.yaml")# Parameters can be accessed in three different ways:print(config.a)print(config["a"])print(config.get("a"))# If the parameter does not exist, AttributeError will be raised# Parameters can be set in three different ways:config.a="b"config.set("a","c")config["a"]="e"# You can save your changes to the yaml file# If you pass an extra argument, it will save the yaml file on that pathconfig.save("new_config.yaml")
测试
“test”文件夹中提供的单元测试。您可以使用以下命令运行它们:
^{pr2}$参考文献
This Stack Overflow answer帮助我计算 介绍如何将YAML文件转换为一个可以使用点(.)运算符访问的对象
This blog post帮助我合并yaml文件 配置对象
- 项目
标签: