Tomli is a Python library for parsing TOML (Tom's Obvious, Minimal Language) files, fully compatible with TOML v1.0.0. As of version 2.4.1, it provides a backport of the standard library's `tomllib` module introduced in Python 3.11, ensuring compatibility for earlier Python versions. The library is actively maintained, with regular updates to enhance functionality and maintain compatibility.
pip install tomliVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to parse a TOML file named 'config.toml' and print its contents as a Python dictionary.
Use the 'tomli-w' library for writing TOML files.
Ensure files are opened with the 'rb' mode when using tomli.load().
Be aware that parsing and re-serializing a TOML file will lose comments and original formatting.
Ensure that the required TOML file (e.g., 'config.toml') exists in the working directory or at the specified path before running the application.
Verify that the TOML file exists at the specified path relative to the script's execution. Provide the correct file path or ensure the file is present.
pip install tomli
Verify the existence and correct path of your TOML file, ensuring it's accessible to the script, e.g., 'path/to/your/config.toml'.
Escape literal backslashes using `\\` (e.g., change `\s` to `\\s`) or use a literal string; only specific escape sequences are allowed in TOML basic strings.
Review your TOML file and ensure all keys within any given table are unique; rename or remove duplicate key definitions.
No dependency data recorded yet.