pythonic层次配置分析器

pyerconf的Python项目详细描述


示例配置:

# a value is set with: key : value
# values are typed. allowed types are:
#  - string (simple or double quotes)
#  - boolean (True or False. is case sensitive)
#  - integer

strval : 'this is a string'
boolval: True
intval : 142

# you can define hierarchies with dictionaries
# ! no comma to se
orgchart : {
    boss : 'Mr Goldmine'

    head_office : {
        VP  : 'Miz dho'
        CTO : 'John Bugs'
    }
}

从python加载:

>>> import pyerconf
>>> cfg = pyerconf.Config('./sample.cfg')
>>> print cfg.strval
this is a string
>>> print cfg.orgchart.boss
Mr Goldmine
>>> print cfg.orgchart.head_office
{'VP': 'Miz dho', 'CTO': 'John Bugs'}

>>> print cfg.foobar
AttributeError

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

推荐PyPI第三方库


热门话题
java Clojure关键字在内存中的大小是多少?   Java中有固定长度的通用数组对象吗?   PostgreSQL:通过Java更新我的用户表   错误:使用java解析xml   java Json显示列表中对象的名称   java比较JodaTime时区   与JAVA中的API和包的区别?   java的int值在for循环中不改变   谷歌应用引擎中的java RSA   迁移到spring 5后出现java非法字符错误   java Websphere管理控制台不工作   JavaGSON如何始终在json中包含毫秒?   带有空格和双引号的windows Java ProcessBuilder命令参数失败   java错误:重复的zip条目[43.jar:org/apache/http/annotation/NotThreadSafe.class]