2 configparser模块(了解)
1 配置文件格式
-xx.xml java项目的配置文件用的多(mycat:配置文件就是xml格式)
-supervisord.conf supervisor的配置文件(configparser)
# 解析xx.conf格式的配置文件
import configparser
# from configparser import ConfigParser
# config=ConfigParser()
# config.read('a.conf')
# res=config.sections()
# print(res)
# res2=config.options('main')
# print(res2)
# res3=config.items('main2')
# print(res3)
# res4=config.get('main2','name')
# res4=config.get('main2','sex')
# print(res4)
# res4=config.get('main2','age')
# res4=config.getint('main2','age')
# print(type(res4))
# print(res4)
# res5=config.getboolean('main','is_admin')
# print(res5)
## 写
from configparser import ConfigParser
config=ConfigParser()
config.read('a.conf')
config.add_section('lqz')
config.set('lqz','name','lqz')
config.write(open('a.conf','w'))