pip install ini.py
converts an ini file to a python dictionary
; main section
[section]
key = value
key2 = "value2"
key3 = 'value3'
import ini
text = open('config.ini', 'r').read()
config = ini.parse(text)
section = config['section']
print(section['key'], section['key2'], section['key3'])
output
value value2 value3
import ini
config = ini.convert({"section": {"key": "value"}, "section2": {"key2": "value2"}})
print(config)
output
[section]
key = value
[section2]
key2 = value2