我使用的是python3 ConfigParser,我的代码是
conf = configparser.ConfigParser()
cfg_file = open('./config.cfg', 'w')
conf.set(None, 'a', '0')
conf.write(cfg_file)
cfg_file.close()
我希望config.cfg文件中的结果是a : 0
。然而,我得到了a = 0
。有没有办法取代"="具有":"?
将分隔符参数用于ConfigParser
:
当给定"分隔符"时,它将用作子字符串集将键与值分开。
conf = configparser.ConfigParser(delimiters=':')
结果:
[DEFAULT]
a : 0