Python Language configparser Basic usage


Example

In config.ini:

[DEFAULT]
debug = True
name = Test
password = password

[FILES]
path = /path/to/file

In Python:

from ConfigParser import ConfigParser
config = ConfigParser()

#Load configuration file
config.read("config.ini")

# Access the key "debug" in "DEFAULT" section
config.get("DEFAULT", "debug")
# Return 'True'

# Access the key "path" in "FILES" destion
config.get("FILES", "path")
# Return '/path/to/file'