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. python写冒泡排序

    冒泡就是重复地遍历要排序的数列,一次比较两个元素(泡泡),如果他们的顺序错误就把他们交换过来,像泡泡一样,依次按照顺序上升排列. 冒泡排序算法的运作如下: 比较相邻的元素.如果第一个比第二个大(升序) ...

  2. Spark RDD的弹性到底指什么

    RDD(Resiliennt Distributed Datasets)抽象弹性分布式数据集对于Spark来说的弹性计算到底提现在什么地方? 自动进行内存和磁盘数据这两种存储方式的切换 Spark 可 ...

  3. 用WPF实现大数据分析,超炫的效果,还带地图

    开头语 经过一段时间研究,终于实现CS和BS相同效果的大数据展示平台了.首先来看看实现的效果,超炫的效果,客户特别喜欢,个人也非常满意,分享给各位,同大家一起交流学习. 大数据展示平台 从上图可以看出 ...

  4. Linux Centos7 环境基于Docker部署Zookeeper服务搭建实战

    配置Zookeeper安装目录 在宿主机配置zookeeper安装目录:/docker/develop/zookeeper 并且在文件夹创建 data 和logs 目录: mkdir -p /dock ...

  5. 中小型企业级 IPS 部署

    <构建基于Snort+Guardian+Iptables的IPS> 2020年的第三天,依旧如往常写文章,分享最近做的项目继<中小型企业级防火墙部署>之后的另一部分<构建 ...

  6. JSONP Hijackin攻击详解

    JSONP Hijackin的中文意思是JSON劫持,而能产生JSON数据劫持的原因在于前端被跨站攻击了.跨站=跨域,跨域从字面上理解的话,就是指超出了范围.领域.继续追问一下,那超出了什么范围?原来 ...

  7. 「Luogu P2508」[HAOI2008]圆上的整点 解题报告

    题面 给定圆的半径,求圆上整点数 这是一道很Nice的数学题!超爱!好吧,由于这道题,我去Study了一下复数(complex number)复杂的数 真棒!!! 有兴趣的戳这里!!!\(\huge ...

  8. JWT实现授权认证

    目录 一. JWT是什么 二. JWT标准规范 三. 核心代码简析 四. 登录授权示例 五. JWT 使用方式 六. JWT注意事项 一. JWT是什么 JSON Web Token(JWT)是目前最 ...

  9. vue开源Element UI表单设计及代码生成器

    在日常的开发工作中,表单开发是较为繁琐且重复的.本文介绍一个我自己写的,提高开发效率的小工具. 1 可视化设计器 设计器基于Element UI ,可通过点击或拖拽的方式设计基本表单, 设计器生成的代 ...

  10. 《图解机器学习-杉山将著》读书笔记---CH2

    CH2 学习模型 重点提炼 学习模型作用: 使特定函数与数据集相近似 学习模型类型: 1.线性模型 (1)最简单的线性模型,缺点:只能表现线性的输入输出函数,不能很好地解决实际问题 (2)基于参数的线 ...