cf = configparser.ConfigParser()
cf.read('文件名')
## 读取
cf.sections()
cf.options(section)
cf.items(option)
cf.get(section, option)
cf.getint(section, option)
## 写入
cf.add_section('名字')
cf.set('section', 'option', 'value')
with open('文件名', ‘w+’) as f:
cf.write(f)
configparser
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)