【python】configparser读写配置文件
2017-09-20 09:03
661 查看
python版本3.6
参考文章:https://docs.python.org/3.6/library/configparser.html
用法:
建立一个test.conf文件,用于读写配置
读写方法
更多用法参考文章 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;【安全】保密,你懂的。
参考文章:https://docs.python.org/3.6/library/configparser.html
用法:
建立一个test.conf文件,用于读写配置
[DEFAULT] ServerAliveInterval = 45 Compression = yes CompressionLevel = 9 ForwardX11 = yes [bitbucket.org] User = hg [topsecret.server.com] Port = 50022 ForwardX11 = no
读写方法
# -* - coding: UTF-8 -* - import configparser conf = 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;【安全】保密,你懂的。
相关文章推荐
- Python自动化测试 (二) ConfigParser模块读写配置文件
- 用ConfigParser模块读写配置文件——Python
- Python自动化测试 -ConfigParser模块读写配置文件
- Python模块之ConfigParser - 读写配置文件
- Python模块之ConfigParser - 读写配置文件
- python--ConfigParser读写改配置文件
- python3 configparser对配置文件读写
- python读写配置文件ConfigParser
- Python模块之ConfigParser - 读写配置文件
- Python - ConfigParser模块读写配置文件
- Python使用自带的ConfigParser模块读写ini配置文件
- Python自动化测试 (二) ConfigParser模块读写配置文件
- Python模块之ConfigParser - 读写配置文件
- Python使用自带的ConfigParser模块读写ini配置文件
- configparser模块读写ini配置文件
- python configparser配置文件解析器
- Python编程:configparser读写ini配置文件
- python读conf配置文件--ConfigParser
- python3配置文件模块configparser.ConfigParser
- python读取配置文件configparser