python 之ConfigParser模块
2011-07-13 22:33
141 查看
ConfigParser是用来处理ini格式的配置文件的Python标准库.
函数 :
read(self, filenames):直接读取ini文件内容。
sections(self):得到所有的section,并以列表的形式返回。
options(self, section):得到指定section的所有option.
get(self, section, option, raw=False, vars = None):得到section中option的值,返回为string类型.
set(self,section, option, value): 对section中的option进行设置,其值为value。
实例:
[portal]
url = http://%(host)s:%(port)s/portal host = localhost
port = 8080
函数 :
read(self, filenames):直接读取ini文件内容。
sections(self):得到所有的section,并以列表的形式返回。
options(self, section):得到指定section的所有option.
get(self, section, option, raw=False, vars = None):得到section中option的值,返回为string类型.
set(self,section, option, value): 对section中的option进行设置,其值为value。
实例:
[portal]
url = http://%(host)s:%(port)s/portal host = localhost
port = 8080
from ConfigParser import ConfigParser config = ConfigParser() config.read(filename) url = config.get('portal', 'url') print url >>> http://localhost:8080/portal[/code]
相关文章推荐
- python配置文件操作——configparser模块
- 【python】 ConfigParser模块
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- Python—ConfigParser模块
- python的 ConfigParser模块
- python-ConfigParser模块【读写配置文件】
- python中configParser模块的基础用法
- python-ConfigParser模块【读写配置文件】
- Python3之configparser模块
- python基础之正则表达式爬虫应用,configparser模块和subprocess模块
- python的ConfigParser模块
- python-configparser模块
- python 中对配置文件(如.ini文件)进行读写等操作ConfigParser模块
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- Python使用ConfigParser模块操作配置文件的方法
- Python中ConfigParser模块的使用
- python-ConfigParser模块【读写配置文件】