Python tomllib Module
Example
Parse TOML format configuration:
import tomllib
toml_str = 'name = "Emil"\nage = 30'
data = tomllib.loads(toml_str)
print(f"Name: {data['name']}, Age: {data['age']}")
Try it Yourself »
Definition and Usage
The tomllib module reads TOML (Tom's Obvious Minimal Language) configuration files.
Use it to parse TOML files into Python dictionaries for application configuration and data storage.
Members
Member | Description |
---|---|
TOMLDecodeError | Exception raised when TOML parsing fails. |
load() | Parse TOML from a binary file. |
loads() | Parse TOML from a string. |