python ConfigParser 模块学习
来源:互联网 发布:ubuntu上配置samba 编辑:程序博客网 时间:2024/06/06 14:07
因为要用到配置文件,所以自己查了下python有这么个模块ConfigParser.然后就学了下,超级的简单
[mysqld]
datadir=/search/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
主要由以下几个API
1.获取一个ConfigParser对象
conf=ConfigParser.ConfigParser()
2.获取配置文件的内容
conf.read(“test.cfg”)
3.获取所有的section,list类型
secs=conf.sections()
print secs
4.获取某个section下面的option ,list类型
options=conf.options(sec)
5.获取某个option的value
value=conf.get(section,option)
6.设置某个option的value
conf.set(section,option,value)
但是需要写回cf.write(open("test.conf", "w"))
7.添加section
conf.add_section(section)
conf.write(fp)
8.删除section
conf.remove_section(section)
conf.write(fp)
9.删除option
conf.remove_option(section,option)
conf.write(fp)
- python ConfigParser 模块学习
- python-ConfigParser模块学习
- python ConfigParser模块学习
- ConfigParser模块学习: 用python解析配置文件
- Python 模块学习 —— ConfigParser
- Python——configParser模块学习
- PYTHON 配置文件模块 ConfigParser
- Python模块之: ConfigParser
- python 之ConfigParser模块
- Python ConfigParser模块
- Python Configparser模块
- python 的 ConfigParser 模块
- Python-ConfigParser模块简介
- python模块之ConfigParser
- Python ConfigParser模块教程
- python ConfigParser模块
- python ConfigParser模块详解
- python 模块configparser
- JQuery常用的方法
- 十六进制转八进制
- hdu2955robberies
- 使用gdb调试android原生程序
- unable to locate package的问题
- python ConfigParser 模块学习
- HDU 4622 Reincarnation
- HDU 4509 湫湫系列故事——减肥记II
- 数列特征
- nmap的参数详解
- SpringMVC 文件上传配置,多文件上传,使用的MultipartFile
- 根据表生成持久化类和映射文件
- jQuery $.post $.ajax用法
- HashSet不能存放相同元素的原因