An alternative handler
for interpolation which implements a more advanced syntax, used for
instance in zc.buildout. Extended interpolation is using
${section:option} to denote a value from a foreign section.
Interpolation can span multiple levels. For convenience, if the
section: part is omitted, interpolation defaults to the current
section (and possibly the default values from the special section).
For example, the configuration specified above with basic
interpolation, would look like this with extended interpolation:
如果您一直在使用python 2.7,并且需要进行横截面插值,那么使用regexps手工进行插值就足够简单了。
代码如下:
警告:
在Python3.2及更高版本中,这是完全有效的:
编辑:
我刚刚看到您使用的是python 2.4,因此,在python 2.4中无法进行节插值。它是在python 3.2-See section 13.2.5 - ConfigParser Interpolation of values中引入的。
您确实可以访问特殊情况[默认]部分。即使对于较旧版本的Python,也可以通过其他部分的插值来访问此处定义的值。
相关问题 更多 >
编程相关推荐