if self._defaults:
    fp.write('[%s]\n' % DEFAULTSECT)
for key, value in list(self._defaults.items()):
    fp.write('%s = %s\n' % (key, str(value).replace('\n', '\n\t')))
fp.write('\n')
for section in self._sections:
    fp.write('[%s]\n' % section)
for key, value in list(self._sections[section].items()):
    if key != '__name__':
        fp.write('%s = %s\n' % (key, str(value).replace('\n', '\n\t')))
fp.write('\n')
How to remove spaces while writing in INI file- Python