import configparser
def set_value_in_property_file(file_path, section, key, value):
config = configparser.RawConfigParser()
config.read(file_path)
config.set(section,key,value)
cfgfile = open(file_path,'w')
config.write(cfgfile, space_around_delimiters=True) # use flag in case case you need to avoid white space.
cfgfile.close()
set_value_in_property_file("sample.ini","Test","name1","32")