A configuration file has sections and each section has attributes.
The format is as follows:
[Section1]
abc = hello
[Section2]
xyz = world
import configparser
#create a config file
config = configparser.ConfigParser()
config['Section1'] = {'Home': '/home/ubuntu/'}
config['Section2'] = {'Database': 'dbname',
'uid': 'username',
'pwd': 'password'}
with open('service.config', 'w') as configfile:
config.write(configfile)
#read from a config file
config_reader = configparser.ConfigParser()
config_reader.read('service.config')
print(config_reader['Section1]['Home'])