轻量级的人类可读配置? [英] lightweight human-readable config?
问题描述
我希望有一个配置文件与我的python proggie,满足
以下要求:
1)支持key->(值,默认)
2)简单直观地阅读和编辑
3)易于读入python数据结构(字典?)
4)不需要任何重需要的库(我正在分发我的
proggie作为py2exe可执行文件,并且不希望膨胀大小)
你们可以为此建议一些格式吗?谢谢,
max
I want to have a config file with my python proggie, satisfying the
following requirements:
1) support key->(value, default)
2) simple and intuitive to read and edit
3) easyly readable into a python datastructure (a dictionary?)
4) not requiring any heavy libraries needed (I am distributing my
proggie as a py2exe executable and do not want to bloat the size)
can you guys suggest some format for this? thanks,
max
推荐答案
" Maxim Khesin" < ma*@cNvOiSsiPoAnMtech.com>在消息中写道
news:p4 ******************** @ twister.nyc.rr.com ...
"Maxim Khesin" <ma*@cNvOiSsiPoAnMtech.com> wrote in message
news:p4********************@twister.nyc.rr.com...
我希望有一个配置文件与我的python proggie,满足
以下要求:
1)支持key->(值,默认)
2)简单直观阅读和编辑
3)易于读入python数据结构(字典?)4)不需要任何繁重的库(我将我的
proggie作为py2exe可执行文件分发并且不想要膨胀的大小)
你们可以为此建议一些格式吗?谢谢,
最多
一个文本文件包含格式为:
key:value
inFile.readlines()中的行
:
key,value = line.split(":")
configdict [key] = value
我通常喜欢添加一个声明来过滤出以#开头的行
角色。
精心品尝。
John Roth
I want to have a config file with my python proggie, satisfying the
following requirements:
1) support key->(value, default)
2) simple and intuitive to read and edit
3) easyly readable into a python datastructure (a dictionary?)
4) not requiring any heavy libraries needed (I am distributing my
proggie as a py2exe executable and do not want to bloat the size)
can you guys suggest some format for this? thanks,
max
A text file containing lines formatted as:
key: value
for line in inFile.readlines():
key, value = line.split(":")
configdict[key] = value
I usually like to add a statement that filters out lines
that start with a "#" character.
Elaborate to taste.
John Roth
John Roth写道:
John Roth wrote:
" Maxim Khesin" < ma*@cNvOiSsiPoAnMtech.com>在消息中写道
新闻:p4 ******************** @ twister.nyc.rr.com ......
"Maxim Khesin" <ma*@cNvOiSsiPoAnMtech.com> wrote in message
news:p4********************@twister.nyc.rr.com...
我希望有一个配置文件与我的python proggie,满足
以下要求:
1)支持key->(值,默认)
2)简单直观阅读和编辑
3)易于读入python数据结构(字典?)4)不需要任何繁重的库(我将我的
proggie作为py2exe可执行文件分发并且不想要膨胀的大小)
你们可以为此建议一些格式吗?谢谢,
最后
一个文本文件,其中包含格式为:
key:value
的inFile.readlines()中的行:
key,value = line.split(":")
configdict [key] = value
我通常喜欢添加一个过滤掉行的声明
以#开头精致。
精致品味。
John Roth
I want to have a config file with my python proggie, satisfying the
following requirements:
1) support key->(value, default)
2) simple and intuitive to read and edit
3) easyly readable into a python datastructure (a dictionary?)
4) not requiring any heavy libraries needed (I am distributing my
proggie as a py2exe executable and do not want to bloat the size)
can you guys suggest some format for this? thanks,
max
A text file containing lines formatted as:
key: value
for line in inFile.readlines():
key, value = line.split(":")
configdict[key] = value
I usually like to add a statement that filters out lines
that start with a "#" character.
Elaborate to taste.
John Roth
你可以试试
这种格式已经可以作为遵循.ini
格式(RFC 822)的python模块。
格式是这样的
[SECTION]
varname1:var
varname2:var
varname3:var
varname4:var
....
使用-OO编译,其大小为。
30.10.2003 00:33 13 483 ConfigParser.pyo
享受 - Noen
You could try out
This format is already avaiable as a python module following the .ini
format (RFC 822).
The format is like this
[SECTION]
varname1: var
varname2: var
varname3: var
varname4: var
....
Compiled using the -OO, its size is.
30.10.2003 00:33 13 483 ConfigParser.pyo
Enjoy -- Noen
2003年10月29日星期三22:22:13 GMT,
Maxim Khesin< ma*@cNvOiSsiPoAnMtech.com>写道:
On Wed, 29 Oct 2003 22:22:13 GMT,
Maxim Khesin <ma*@cNvOiSsiPoAnMtech.com> wrote:
我希望有一个配置文件与我的python proggie,满足
以下要求:
1)支持key->(值,默认2)简单直观的阅读和编辑
3)易于读取到python数据结构(字典?)
4)不需要任何繁重的库(我正在分发我的
proggie作为py2exe可执行文件,并且不希望膨胀大小)
你们可以为此建议一些格式吗?谢谢,
I want to have a config file with my python proggie, satisfying the
following requirements:
1) support key->(value, default)
2) simple and intuitive to read and edit
3) easyly readable into a python datastructure (a dictionary?)
4) not requiring any heavy libraries needed (I am distributing my
proggie as a py2exe executable and do not want to bloat the size) can you guys suggest some format for this? thanks,
标准库ConfigParser可以工作吗?点击你的网站
浏览器:
http://www.python.org/doc/current/li...figParser.html
问候,< br $> b $ b希瑟
-
Heather Coppersmith
这是不对的;那甚至没错。 - Wolfgang Pauli
Will the standard library ConfigParser work? Point your web
browser here:
http://www.python.org/doc/current/li...figParser.html
Regards,
Heather
--
Heather Coppersmith
That''s not right; that''s not even wrong. -- Wolfgang Pauli
这篇关于轻量级的人类可读配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!