Home > database >  How to retrieve key, value from config.ini?
How to retrieve key, value from config.ini?

Time:07-12

i want to read certain data from a config file as key,value

i found below way to define the key value in config.ini

[Section]
value={"name":"John","id":"101"}

but not seeing the way to parse this value as dictionary in python i actually need to retrieve each key value from 'Section value'

Any right solution to this?

CodePudding user response:

You can read the value as usual string then parse it with json package

import configparser
import json

config = configparser.ConfigParser()
config.read('config.ini')
string = config['Section']['value']
obj = json.loads(string)
  • Related