Article From:

ymal : It’s a config file

# !/user/bin/python
# -*- coding: utf-8 -*-

import configparser

# Generate a config file, which generates a example.ini file under the current directory.
config = configparser.ConfigParser()

config["default"] = {"ServerAliveInterval": "45",

config[""] = {}
config[""]["user"] = "hg"
config[""] = {}
topsecret = config[""]
topsecret["host port"] = "5002"
topsecret["portwardxii"] = "no"

with open("example.ini","w") as configfile:

# Read the config file
conf = configparser.ConfigParser()"example.xml")

print(conf.sections())  # Print out the contents of the file, that is, [[default]], but the default is not printed.
print(conf.default_section)  # Print the default node, that is, [default]
print(conf['']['user'])  # Read the contents of the specified node. Why read failed? TODO


Leave a Reply

Your email address will not be published. Required fields are marked *