configparser
suggest changeSyntax
- A setting is a key-value pair separated by
= - Keys can be grouped in sections
- In the INI file, each section title is written between brackets:
[]
Remarks
Creating configuration file programmatically
The output file contains the structure below. The code that writes it is not shown.
[settings]
resolution = 320x240
color = blue
If you want to change a particular field, get the field and assign the value. config is not defined in this fragment.
settings=config['settings']
settings['color']='red'
Basic usage
In config.ini:
[DEFAULT]
debug = True
name = Test
password = password
[FILES]
path = /path/to/file
In Python:
The Python that reads this file is not shown.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents