Monday 6 March 2017

Python code to get ini data with Example

"""
Write the required data to be passed in a notepad & save that file with "ini" extention.
Place the below code in the python file.
"""
Example:



Code:
def getIniData(section):
    config = configparser.ConfigParser()
    config.optionxform = str
    config.read("testconfig.ini")
    section_dict = {}
    for option in config.options(section):
        section_dict[option] = config.get(section, option)
    return section_dict



No comments:

Post a Comment