1. 首页
  2. 数据库
  3. 其它
  4. python解析模块(ConfigParser)使用方法

python解析模块(ConfigParser)使用方法

上传者: 2020-12-31 11:29:01上传 PDF文件 33KB 热度 37次
测试配置文件test.conf内容如下: 复制代码 代码如下:[first]w = 2v: 3c =11-3 [second] sw=4test: hello 测试配置文件中有两个区域,first和second,另外故意添加一些空格、换行。 下面解析: 复制代码 代码如下:>>> import ConfigParser>>> conf=ConfigParser.ConfigParser()>>> conf.read(‘test.conf’)[‘test.conf’]>>> conf.sections() #获得所有区域[‘first’, ‘second’]>>> for sn in con
下载地址
用户评论