import configparser
# ConfigParser模块
# 生成一个configparser
config = configparser.ConfigParser()
config.add_section('666')
config.set('666', 'hnm1', '1')
config.set('666', 'hnm2', '2')
with open('aoao.cnf', 'w') as cfg:
config.write(cfg)
# 读取configparser
config = configparser.ConfigParser()
config.read('my.cnf')
print(config.sections())
print(config['mysqld']['join_buffer_size'])
# 删除一个section
sec = config.remove_section('mysqld')
config.write(open('my.cnf','w'))
# 判断有没有sections
sec = config.has_section('mysqld1')
print(sec)