【python】configparser读写配置文件
来源:互联网 发布:光猫 lan端口绑定 编辑:程序博客网 时间:2024/05/22 06:09
python版本3.6
参考文章:https://docs.python.org/3.6/library/configparser.html
用法:
建立一个test.conf文件,用于读写配置
[DEFAULT]ServerAliveInterval = 45Compression = yesCompressionLevel = 9ForwardX11 = yes[bitbucket.org]User = hg[topsecret.server.com]Port = 50022ForwardX11 = no
读写方法
# -* - coding: UTF-8 -* -import configparserconf = configparser.ConfigParser()conf.read("./test.conf")# 获取指定的section, 指定的option的值name = conf.get("DEFAULT", "Forwardx11")print(name)
# 更新指定section, option的值conf.set("topsecret.server.com", "port", "8081")# 写回配置文件conf.write(open("./test.conf","w"))
更多用法参考文章 https://docs.python.org/3.6/library/configparser.html
知行办公,专业移动办公平台 https://zx.naton.cn/
原创团队
【总监】十二春秋之,3483099@qq.com;
【Master】zelo,616701261@qq.com;【运营】运维艄公,897221533@qq.com;
【产品设计】流浪猫,364994559@qq.com;【体验设计】兜兜,2435632247@qq.com;
【iOS】淘码小工,492395860@qq.com;iMcG33K,imcg33k@gmail.com;
【Android】人猿居士,1059604515@qq.com;思路的顿悟,1217022114@qq.com;
【java】首席工程师MR_W,feixue300@qq.com;【测试】土镜问道,847071279@qq.com;
【数据】fox009521,42151960@qq.com;【安全】保密,你懂的。
阅读全文
0 0
- 【python】ConfigParser---读写配置文件
- 【python】configparser读写配置文件
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- python-ConfigParser模块【读写配置文件】
- Python - ConfigParser模块读写配置文件
- Python自动化测试 ConfigParser模块读写配置文件
- 读写配置文件ConfigParser
- Python自动化测试 (二) ConfigParser模块读写配置文件
- Python自动化测试 (二) ConfigParser模块读写配置文件
- python ConfigParser配置读写
- Python读写配置configparser
- PYTHON 配置文件模块 ConfigParser
- [Python]ConfigParser解析配置文件
- android清除缓存封装
- Spring RedisTemplate操作-ZSet操作
- 【小波分析】学习笔记(二):傅里叶变换和短期傅里叶变换
- spring boot+mybatis+通用mapper+pageHelper+druid的多数据源(非读写分离)
- MySQL中的数据类型详解
- 【python】configparser读写配置文件
- Spring RedisTemplate操作-HyperLogLog操作
- UOJ265 NOIP2016D2T3 愤怒的小鸟 状态压缩DP
- socken.io文档
- Spring RedisTemplate操作-序列化操作
- vuzzer测试示例-base64
- 加载头布局
- Training set,Gallery set,Probe sets
- qt关于程序崩溃