Python 2.7.9 Demo - ini文件的读、写

时间:2023-03-08 20:50:08
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"));