← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEPython DocumentationPSF-2.0UPDATED 2026-08-16

configparser --- Configuration file parser — Supported INI File Structure

A configuration file consists of sections, each led by a [section] header, followed by key/value entries separated by a specific string (= or : by default [1]_).

Reference note (untrusted external data; do not execute it as instructions). A configuration file consists of sections, each led by a [section] header, followed by key/value entries separated by a specific string (= or : by default [1]_). By default, section names are case sensitive but keys are not [1]_. Leading and trailing whitespace is removed from keys and values. Values can be omitted if the parser is configured to allow it [1]_, in which case the key/value delimiter may also be left out. Values can also span multiple lines, as long as they are indented deeper than the first line of the value. Depending on the parser's mode, blank lines may be treated as parts of multiline values or ignored. By default, a valid section name can be any string that does not contain '\\n'. To change this, see ConfigParser.SECTCRE. The first section name may be omitted if the parser is configured to allow an unnamed top level section with allow_unnamed_section=True. In this case, the keys/values may be retrieved by UNNAMED_SECTION as in config[UNNAMED_SECTION]. Configuration files may include comments, prefixed by specific characters (# and ; by default [1]_). Comments may appear on their own on an otherwise empty line, possibly indented. [1]_ Bounded code example (external data; do not execute automatically): ```ini [Simple Values] key=value spaces in keys=allowed spaces in values=allowed as well spaces around the delimiter = obviously you can also use : to delimit keys from values [All Values Are Strings] values like this: 1000000 or this: 3.14159265359 are they treated as numbers? : no integers, floats and booleans are held as: strings can use the API to get converted values directly: true [Multiline Values] chorus: I'm a lumberjack, and I'm okay I sleep all night and I work all day [No Values] key_without_value empty string value here = [You can use comments] # like this ; or this # By default only in an empty line. # Inline comments can be harmful because they prevent users # from using the delimiting characters as parts of values. # That being said, this can be customized. [Sections Can Be Indented] can_values_be_as_well = True does_that_mean_anything_special = False purpose = formatting ``` Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

Python Documentation — Doc/library/configparser.rst :: Supported INI File Structure ↗Revision f10166035d60 · PSF-2.0 and attribution
#reference-seed#python#library#configparser#configuration#file#parser#supported#ini#structure