ConfigParser模块的应用

#ConfigParser模块的应用

#! /usr/bin/python

#-*- coding: utf-8 -*-

from ConfigParser import ConfigParser

conf = ConfigParser()

conf.read('test.cfg')

sections = conf.sections()

print 'sections:', sections

options = conf.options('FSFB2_GLOBAL')

print 'options:',options

kvs = conf.items('FSFB2_GLOBAL')

print 'kvs:',kvs

value = conf.get('FSFB2_GLOBAL','main_cycle')

print 'value:',value

new = conf.set('FSFB2_GLOBAL', 'main_cycle', '11')

print 'new:',new

value = conf.get('FSFB2_GLOBAL','main_cycle')

print 'value:',value

newsection = conf.add_section('new main_cycle')

sections = conf.sections()

print 'sections:', sections

你可能感兴趣的:(ConfigParser模块的应用)