ConfigParser---python

# !/usr/bin/python

# Filename:tcfg.py



import ConfigParser



config = ConfigParser.ConfigParser()

config.read("/home/xxx/xxx/tcfg.ini")



print



secs = 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")

print

print 'svn=',svn

print 'ip=',ip

 

你可能感兴趣的:(python)