Python中configparser模块的使用方法-创新互联
这篇文章主要讲解了Python中configparser模块的使用方法,内容清晰明了,对此有兴趣的小伙伴可以学习一下,相信大家阅读完之后会有帮助。

1、生成配置文件
'''
生成配置文件
'''
import configparser
config = configparser.ConfigParser()
# 初始化赋值
config["DEFAULT"] = {'ServerAliveInterval': '45',
'Compression': 'yes',
'CompressionLevel': '9'}
# 追加
config['DEFAULT']['ForwardX11'] = 'yes'
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) 本文标题:Python中configparser模块的使用方法-创新互联
文章来源:http://www.jxjierui.cn/article/gijjo.html


咨询
建站咨询
