python 模块configparser
来源:互联网 发布:读音软件 编辑:程序博客网 时间:2024/06/03 14:11
模块的名称在 python 3.x 版本中变更为 configparser
实例:
import configparserconfig = configparser.ConfigParser()config["DEFAULT"]={ "ServiceAliveInterval":"45", "Compression":"yes", 'CompressionLevel': '9'}config["bitbucket.org"]={ "user":"hg"}config['topsecret.server.com'] = {}topsecret = config['topsecret.server.com']topsecret["host port "] ="50022"topsecret["forwardx11"] ="no"config["DEFAULT"]["forwardx11"] = "yes"with open("file_configparser","w")as fp: config.write(fp)print(config.sections()) #读取除了default之外的标题# for i in config["bitbucket.org"]:# print(i)print(config["bitbucket.org"]["user"])configparser增删改查语法
[section1]
k1
=
v1
k2:v2
[section2]
k1
=
v1
import
ConfigParser
config
=
ConfigParser.ConfigParser()
config.read(
'i.cfg'
)
# ########## 读 ##########
#secs = config.sections()
#print secs
#options = config.options('group2')
#print options
#item_list = config.items('group2')
#print item_list
#val = config.get('group1','key')
#val = config.getint('group1','key')
# ########## 改写 ##########
#sec = config.remove_section('group1')
#config.write(open('i.cfg', "w"))
#sec = config.has_section('zongyimin')
#sec = config.add_section('zongyimin')
#config.write(open('i.cfg', "w"))
#config.set('group2','k1',11111)
#config.write(open('i.cfg', "w"))
#config.remove_option('group2','age')
#config.write(open('i.cfg', "w"))
0 0
- 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
- Python模块之ConfigParser
- Python模块之ConfigParser
- Python—ConfigParser模块
- python ConfigParser模块简介
- Struts2 几种校验
- 非const对象也可以调用const成员函数
- Linux中crontab的环境变量问题
- POI解析excel表格
- svm 支持向量机
- python 模块configparser
- Sturts2 初学学习笔记 4
- 工厂模式,常用的设计模式(创建型模式)及分类
- javaXML文件解析(一) SAX解析
- vx弹出搜索框 多条件查询
- RecycleView的方法
- Android学习笔记第五篇--网络连接与云服务(一)
- 【转载】前端面试必知的50道题目汇总
- AB 液体发泡硅胶(双组份发泡硅胶)IOTA 663A,B