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")
python 更改配置文件 key value 值
最新推荐文章于 2022-11-03 17:05:58 发布