美文网首页python
python Config API

python Config API

作者: wit92 | 来源:发表于2020-06-13 00:05 被阅读0次

    (1).init(key, default, type=None, comment=None)

    Initializes key to the given default value.
    If type is not provided, the type of the default value will be used.
    If a value is already set for the section at key, it will be coerced to type.
    If a comment is provided, it may be written out to the config file in a manner consistent with the active Format.
    

    将键初始化为给定的默认值。

    如果类型未提供,则默认值的类型将被使用。

    如果已经为key部分设置了一个值,则会强制它键入。

    如果提供了注释,则可以以与活动一致的方式将其写入配置文件Format。

    (2).read(*sources, **kwargs)

    Reads config values.
    If sources are provided, read only from those sources. Otherwise, write to the sources in sources. A format for sources can be set using format.
    

    读取配置值。

    如果提供了来源,请从这些来源中读取。否则,写入源中sources。一种用于格式 源可以使用设置格式。

    (3)sync(*sources, **kwargs)

    Reads from sources and writes any changes back to the first source.
    If sources are provided, syncs only those sources. Otherwise, syncs the sources in sources.
    format can be used to override the format used to read/write from the sources.
    

    从源读取并将任何更改写回第一个源。

    如果提供了源,则仅同步这些源。否则,同步源sources。

    format可用于覆盖用于从源读取/写入的格式。

    (4)get(key, default=None)

    If key exists, returns the value. Otherwise, returns default.
    If default is not given, it defaults to None, so that this method never raises an exception.
    

    相关文章

      网友评论

        本文标题:python Config API

        本文链接:https://www.haomeiwen.com/subject/uqytxktx.html