python四十:configparse模块

# 创建配置文档
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'] = '55555'
topsecret['ForwardXll'] = 'no'

with open('example.ini', 'w') as configfile:
    config.write(configfile)

猜你喜欢

转载自blog.csdn.net/m0_37564426/article/details/83016552