标签:
import ConfigParser,os os.chdir(‘C:\\Users\\hito\\Desktop‘) cf = ConfigParser.ConfigParser() cf.read(‘test.ini‘) a=cf.get(‘section1‘,‘option1‘) print a+‘a‘ b=cf.getint(‘section1‘,‘option1‘) print a+2
import ConfigParser,os os.chdir(‘C:\\Users\\hito\\Desktop‘) cf = ConfigParser.ConfigParser() cf.add_section("section1") cf.set("section1", "option1", 1) cf.add_section("section2") cf.set("section2", "option2", "value2") # write to file with open("test.ini","w+") as f: cf.write(f)
标签:
原文地址:http://www.cnblogs.com/hito/p/4651647.html