基本用法

在 config.ini 中:

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

[FILES]
path = /path/to/file

在 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'