处理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文件 配置对象

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么会出现这些错误?表达式的非法开始   使用HttpUrlConnection的java测试URL仅适用于前面的www   在大数据集上使用kmeans的java堆外内存   查找Java RandomAccessFile如何以字符形式读取第n个字节   java Android从BroadcastReceiver获取标题和描述   java使用构造函数参数模拟嵌套类并测试方法   正在将Azure Blob项强制转换为Java文件对象   java并行运行testNG套件   java程序在运行时似乎没有进入   贬低Java规则引擎的优点和缺点   文本区域中的java中心文本   java JPA从多个表中选择错误   类Java问题使用类加载器重新加载代码   java如何在Spring非管理类上使用@Value   java(关闭)Gradle导入VS代码失败   java arraylist拆分(“空白”)并计算字数   Android/Java如何在单独的*中调用函数。java文件?   具有基本身份验证的java Apache Camel RSS模块   java为什么程序在出现溢出或下溢时不抛出异常