首页 > 代码库 > ConfigParser---python

ConfigParser---python

# !/usr/bin/python# Filename:tcfg.pyimport ConfigParserconfig = ConfigParser.ConfigParser()config.read("/home/xxx/xxx/tcfg.ini")printsecs = config.sections()print secs=,secs  #secs= [‘Config‘]opts = config.options("Config")print option = ,opts#option =  [‘svn‘, ‘pwd‘, ‘root‘, ‘ip‘]kvs = config.items(secs[0])print kvs=,kvs#kvs= [(‘svn‘, ‘/home/xxx/wo/relate_platform/controller‘), (‘pwd‘, ‘11111‘), (‘root‘, ‘root‘), (‘ip‘, ‘10.10.10.XX‘)]svn = config.get(secs[0],"svn")ip = config.get(secs[0],"ip")printprint svn=,svnprint ip=,ip