# -*- coding: utf-8 -*-
import ConfigParser
config = ConfigParser.ConfigParser()
config.readfp(open(‘ixamail.ini‘))
a = config.get("host","smtp_server")
print a
config.add_section("book")
config.set("book", "title", "the python standard library")
config.set("book", "author", "fredrik lundh")
config.add_section("ematter")
config.set("ematter", "pages", 250)
# write to file
config.write(open(‘1.ini‘, "w"))
config.read(‘1.ini‘)
a = config.add_section("md5")
config.set("md5", "value", "1234")
config.write(open(‘1.ini‘, "r+"))
ConfigParser 实例 01,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/mhxy13867806343/p/3860915.html