configparser

Stdlib — SerializationPython 2.0+Beginner

Read and write INI-style configuration files

Quick Info

Documentation
Official Docs
Python Version
2.0+
Dependencies
None — Python Standard Library
Install
Included with Python

Learn by Difficulty

Quick Example

python
import configparser
from io import StringIO

config = configparser.ConfigParser()
config.read_string("""
[database]
host = localhost
port = 5432
name = mydb

[app]
debug = true
""")

print(config["database"]["host"])
print(config.getint("database", "port"))
print(config.getboolean("app", "debug"))

The configparser module is part of Python's standard library. Read and write INI-style configuration files.

Try in Playground

Tags

stdlibserializationdata-format