博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
configparser 文件的生成和读写
阅读量:7027 次
发布时间:2019-06-28

本文共 801 字,大约阅读时间需要 2 分钟。

# configparser 生成

import configparser 

config = configparser.ConfigParser()

config[DEFUALT] = {'ServerAliveInterval':45,

                               'Compreassion':'yes',

                              'CompreassionLevel':'9'}

config['bitbucket.rog'] = {}

config['bitbucket.rog']['user'] = 'hg'

config['topsecret.server.com'] = {}

config['topsecret.server.com']['host Port'] = 52222
config['topsecret.server.com']['ForwardXll'] = 'no'
config['DEFAULT']['ForwardXll'] = 'yes'

with open('example.ini') as configfile:

      config.write(configfile)

#configparser 读取

import configparser 

config = configparser.ConfigParser()

config.read('example.ini') #读入文件

config.sections()

config.defaults()

config['bitbucket.org']['User']

sec = config.remove_section('bitbucket.org)  #移除模块

config.write(open('i.fig','w'))  #载入

 

转载于:https://www.cnblogs.com/my-love-is-python/p/9077568.html

你可能感兴趣的文章
MySQL进阶
查看>>
mybatis分页 -----PageHelper插件
查看>>
从移动硬盘启动电脑与重装注意事项
查看>>
深入浅出Tomcat系列
查看>>
从网页提取的关键字
查看>>
杭州手持式超声波流量计的特点汇总
查看>>
位运算符
查看>>
【OCP-12c】CUUG 071题库考试原题及答案解析(18)
查看>>
Centos7系统如何不重启系统识别新添加的硬盘?
查看>>
【Unity Shader】自定义材质面板的小技巧
查看>>
icon文件操作
查看>>
BeatSaber节奏光剑双手柄MR教程
查看>>
分组聚合
查看>>
冒泡排序(bubble sort)
查看>>
eclipse新建JSP页面报错:Multiple annotations found at this line解决方法
查看>>
bzoj3685
查看>>
为什么更喜欢Outlook,而不是Gmail
查看>>
C#中的事件和委托
查看>>
设计模式之(Adapter)适配器模式
查看>>
python中函数的定义、返回值以及参数的简要介绍
查看>>