[section 1]
key1:value1
key2:value2
[section 2]
key1:value1
key2:value2
I have tried to parse this config file into dictionary using python but i was unable to do
This is my code:
import configparser
config = configparser.ConfigParser
filename = '/home/Documents/dictionary parsing/config.cfg'
def read_config_file(filename):
with open(file=filename, mode='r') as fs:
return{k.strip(): v.strip() for i in [l for l in fs.readlines() if l.strip() != ''] for k, v in [i.split('=')]}
print('dictionary: ',read_config_file(filename))