Python 2.7.9 Demo - ini文件的读、写

ini文件

[weixin_info]
hello = Nick Huang

 

#coding=utf-8
#!/usr/bin/python
import ConfigParser;

cp = ConfigParser.ConfigParser();
cp.read('027.99.config.ini');
hello = cp.get('weixin_info', 'hello');
print hello;

 

#coding=utf-8
#!/usr/bin/python
import ConfigParser;

cp = ConfigParser.ConfigParser();

cp.add_section("weixin_info");
cp.set("weixin_info", "hello", "Nick Huang");

cp.write(open('027.99.config.ini', "w"));

 

posted @ 2015-07-02 22:46  nick_huang  阅读(304)  评论(0编辑  收藏  举报