dictionary = {}
for section in config.sections():
    dictionary[section] = {}
for option in config.options(section):
    dictionary[section][option] = config.get(section, option)
Read all the contents in ini file into dictionary with Python