快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Python中configparser模块的使用方法-创新互联

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

成都创新互联公司云计算的互联网服务提供商,拥有超过13年的服务器租用、重庆服务器托管、云服务器、网络空间、网站系统开发经验,已先后获得国家工业和信息化部颁发的互联网数据中心业务许可证。专业提供云主机、网络空间、申请域名、VPS主机、云服务器、香港云服务器、免备案服务器等。

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://6mz.cn/article/gijjo.html

其他资讯