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"));

 

你可能感兴趣的:(python)