python - 如何使用 python 一次加载配置属性而不传递部分名称
问题描述
这是我的方法:
def readConfigProperties(sectionName):
# Using Confir Parser : Import the package First : add interpreter too
config = configparser.RawConfigParser()
config.read('Path To Properties ')
details_dict = dict(config.items(sectionName))
print(details_dict)
return details_dict
目前我正在传递部分名称,这工作正常,但我想一次在之前的场景中加载完整的属性文件。
解决方案
怎么做:
all = {}
for section_name in config.sections():
for name, value in config.items(section_name):
all[name] =value
推荐阅读
- java - 如何根据GPA对数组列表进行升序排序?arraylist 包含一个对象数组。(爪哇)
- javascript - 使用 Reduce 方法在 JavaScript 中反转字符串
- python - Python:当变量被类方法调用时,对象变量存在“NameError”
- mysql - 调用过程时语句不完整
- multiprocessing - 预定义元组数组
- node.js - express 项目在服务器上运行但无法得到任何响应
- python - 为什么我在这个插入排序算法中过度计算了比较的数量?
- python - Matplotlib 自定义标记/符号
- javascript - 登录后 Firebase 身份验证重定向到空白页面
- excel - 使用多个项目参数从 Excel 创建 Revit Sheets