Python ConfigParser的多个配置文件 [英] Multiple configuration files with Python ConfigParser

查看:496
本文介绍了Python ConfigParser的多个配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用ConfigParser.read时,您可以传递与配置文件潜在位置相对应的字符串列表,并且该函数返回已成功读取的那些文件的列表。

When calling ConfigParser.read you are allowed to pass a list of strings corresponding to potential locations for configuration files and the function returns a list of those files that were successfully read.

加载多个配置文件时,如果它们具有重叠的部分/键,默认行为是什么?列表中的较新文件会覆盖较早文件解析的值吗?是整个部分被覆盖还是只是冲突的键?

What is the default behaviour when multiple configuration files are loaded that have overlapping sections/keys? Do later files in the list override values parsed by earlier ones? Is the entire section overridden or just conflicting keys?

推荐答案

经过测试之后,ConfigParser会用每个后续文件覆盖键,读取文件的顺序取决于传递给ConfigParser.read

After getting around to testing it, ConfigParser overwrites the keys with each successive file, the order in which the files are read is determined by the order of the file names in the list passed to ConfigParser.read

这篇关于Python ConfigParser的多个配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆