Structured Data Modules
configparser
Read and write INI-style configuration with sections, string options and optional interpolation. Use getint(), getfloat() or getboolean() for conversion; ordinary values remain strings. Option names are case-insensitive by default and percent interpolation can be disabled for literal values.
Formal Syntax & Structure
python syntaxpython
import configparserReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
import configparserconfig = configparser.ConfigParser()config.read_string("[service]\nport = 8080\nenabled = yes")print(config.getint("service", "port"), config.getboolean("service", "enabled"))