import configparser #配置文件

config = configparser.ConfigParser()
config["DEFAULT"] = {'ServerAliveInterval': '45',
'Compression': 'yes',
'CompressionLevel': '9'} config['bitbucket.org'] = {}
config['bitbucket.org']['User'] = 'hg'
config['topsecret.server.com'] = {}
topsecret = config['topsecret.server.com']
topsecret['Host Port'] = '50022' # mutates the parser
topsecret['ForwardX11'] = 'no' # same here
with open('example.ini', 'w') as configfile:
config.write(configfile)
config.read('example.ini')#用于调用对象
print(config.sections())
print('bytebong.com' in config)#判断
print(config['bitbucket.org']['User'])
print(config['DEFAULT']['Compression']) for key in config['bitbucket.org']:
print(key) print(config.options('bitbucket.org'))#取出键对应的值 【DEFAULT】是默认的 里面的值也会被取出来
print(config.items('bitbucket.org'))#取出键值对 【DEFAULT】是默认的 里面的键值也会被取出来
print(config.get('bitbucket.org','compression'))
config.remove_section('topsecret.server.com')#删除键
config.remove_option('bitbucket.org','user')#删除值
config.set('bitbucket.org','user','11111') #更改键对应的值 config.write(open('example.ini', "w")) #增删改并不是在原文件上修改而是重新覆盖或生成
import configparser #配置文件

config = configparser.ConfigParser()
# config["DEFAULT"] = {'ServerAliveInterval': '45',
# 'Compression': 'yes',
# 'CompressionLevel': '9'}
#
# config['bitbucket.org'] = {}
# config['bitbucket.org']['User'] = 'hg'
# config['topsecret.server.com'] = {}
# topsecret = config['topsecret.server.com']
# topsecret['Host Port'] = '50022' # mutates the parser
# topsecret['ForwardX11'] = 'no' # same here
# with open('example.ini', 'w') as configfile:
# config.write(configfile)
config.read('example.ini')#用于调用对象
# print(config.sections())
# print('bytebong.com' in config)#判断
# print(config['bitbucket.org']['User'])
# print(config['DEFAULT']['Compression'])
#
#
# for key in config['bitbucket.org']:
# print(key)
#
# print(config.options('bitbucket.org'))#取出键对应的值 【DEFAULT】是默认的 里面的值也会被取出来
# print(config.items('bitbucket.org'))#取出键值对 【DEFAULT】是默认的 里面的键值也会被取出来
# print(config.get('bitbucket.org','compression'))
# config.remove_section('topsecret.server.com')#删除键
# config.remove_option('bitbucket.org','user')#删除值
# config.set('bitbucket.org','user','11111') #更改键对应的值
#
# config.write(open('example.ini', "w")) #增删改并不是在原文件上修改而是重新覆盖或生成

config 模块的更多相关文章

  1. SpringCloud创建Config模块

    1.说明 本文详细介绍Spring Cloud创建Config模块的方法, 基于已经创建好的Spring Cloud父工程, 请参考SpringCloud创建项目父工程, 创建Config模块这个子工 ...

  2. logging.config模块---使用配置文件管理logger

    logging配置文件 一.使用到的模块: logging.config 官方文档: https://docs.python.org/3/library/logging.config.html 非官方 ...

  3. Py-re正则模块,log模块,config模块,哈希加密

    9.re正则表达式模块,用于字符串的模糊匹配 元字符: 第一:点为通配符 用.表示匹配除了换行符以外的所有字符 import re res=re.findall('a..x','adsxwassxdd ...

  4. drupal7为admin/config页面添加自己开发的模块

    1.实现显示模块 //admin/config配置页面添加journal块 $items['admin/config/journal'] = array(//注意格式为'admin/config/模块 ...

  5. python学习笔记之常用模块(第五天)

    参考老师的博客: 金角:http://www.cnblogs.com/alex3714/articles/5161349.html 银角:http://www.cnblogs.com/wupeiqi/ ...

  6. 谈谈.net模块依赖关系及程序结构

    技术为解决问题而生. 上面这个命题并非本文重点,我将来有空再谈这个.本文也并非什么了不起的技术创新,只是分享一下我对.net模块依赖关系及程序结构方面的一些看法.先看一个最最简单的hello worl ...

  7. python日志模块---logging

    1.将日志打印到屏幕 import logging logging.debug('This is debug message---by liu-ke') logging.info('This is i ...

  8. Python中的日志管理Logging模块

    1.基本的用法 import logging logging.debug('This is debug message') logging.info('This is info message') l ...

  9. Python(2.7.6) 标准日志模块 - Logging Configuration

    除了使用 logging 模块中的 basicConfig 方法配置日志, Python 的 logging.config 模块中, dictConfig 和 fileConfig 方法分别支持通过字 ...

随机推荐

  1. mybatis精讲(六)--二级缓存

    目录 简介 配置 源码 CachingExecutor 自定义二级缓存 # 加入战队 微信公众号 简介 上一章节我们简单了解了二级缓存的配置.今天我们详细分析下二级缓存以及为什么不建议使用二级缓存. ...

  2. 0017 CSS 三大特性:层叠性、继承性、优先级

    目标: 理解 能说出css样式冲突采取的原则 能说出那些常见的样式会有继承 应用 能写出CSS优先级的算法 能会计算常见选择器的叠加值 5.1 CSS层叠性 概念: 所谓层叠性是指多种CSS样式的叠加 ...

  3. CodeForces - 1239A

    推公式题,万万没想到斐波那契啊

  4. MyBatis学习与使用(一)

    写在前面—— 用 MyBatis 也做过几个项目了,但是一直没有很深入的去理解这个框架,最近决定从头开始学习和整理MyBatis. 之前开发的项目并不是我先创建的,等我介入的时候发现他们已经稍稍封装了 ...

  5. OpenSsl库 Rsa的简单使用

    环境的配置可以参考http://www.cnblogs.com/yangyquin/p/5284530.html 网络上传输的数据很容易被抓包,如果不加密,那么网络数 据很容易被窃取,诸如用户名.密码 ...

  6. Windows To Go 企业版2019 LTSC 开发环境部署

    Windows To Go 是一项非常实用的功能,与传统方式安装Windows 10相比更具有灵活性,会根据每次接入的硬件型号保留不同版本驱动. 由于博主是一名全栈程序员(截至发稿处于菜鸟级别),对灵 ...

  7. 基于 HTML5 WebGL 与 WebVR 3D 虚实现实的可视化培训系统

    前言 2019 年 VR, AR, XR, 5G, 工业互联网等名词频繁出现在我们的视野中,信息的分享与虚实的结合已经成为大势所趋,5G 是新一代信息通信技术升级的重要方向,工业互联网是制造业转型升级 ...

  8. 机器学习实战笔记(一)- 使用SciKit-Learn做回归分析

    一.简介 这次学习的书籍主要是Hands-on Machine Learning with Scikit-Learn and TensorFlow(豆瓣:https://book.douban.com ...

  9. 8.在python中用data_only=True设置显示excel表格中公式的结果为None的解决方法

    在用python调用excel文件显示带公式的表格内容,有两种显示结果:第一种是直接显示表格中公式人内容:另一种是显示其表格中公式的结果. 显示第一种,可以这样输入代码: 显示第二种,可以这样输入代码 ...

  10. KMP 和 扩展KMP

    KMP:在主串S中找子串T的位置KMP算法的时间复杂度O(|S|+|T|). #define maxn 1000 char s[maxn],t[maxn];//s为主串,t为子串 int net[ma ...