首页 > 解决方案 > 如何使用 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

目前我正在传递部分名称,这工作正常,但我想一次在之前的场景中加载完整的属性文件。

标签: pythonautomationpython-3.8

解决方案


怎么做:

all = {} 
for section_name in config.sections():
    for name, value in config.items(section_name):
        all[name] =value
 


推荐阅读