这篇文章主要讲解了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模块的使用方法-创新互联
URL分享:https://www.cdcxhl.com/article20/gijjo.html
成都网站建设公司_创新互联,为您提供企业建站、标签优化、定制开发、域名注册、云服务器、用户体验
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联