python 读取配置文件方法

#coding=utf8

import ConfigParser

config = ConfigParser.ConfigParser()
config.readfp(open(raw_input("input file name:"), "rb"))
print config.get("global", "ip")

  

config.ini

[global]
ip = 192.168.1.100 ;ip地址
port = 3306
password = 123456

posted @ 2013-06-19 14:19  践道者  阅读(17460)  评论(0编辑  收藏  举报