configparser读

#-*-coding:utf-8-*-
__author__ = "logan.xu"


import configparser

conf = configparser.ConfigParser()
conf.read("example.ini")

print(conf.defaults())
print(conf['bitbucket.org']['user'])
#改写

sec = conf.remove_section('bitbucket.org')
conf.write(open('example.ini',"w"))

#conf.write(open('example.cfg',"w"))


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

OrderedDict([('serveraliveinterval', '45'), ('compression', 'yes'), ('compressionlevel', '9'), ('forwardx11', 'yes')])
hg

posted @ 2018-04-24 17:00  裸奔的小鸵鸟  阅读(228)  评论(0编辑  收藏  举报