On this page
tomllib.loads
Prev: tomllib.load | Up: tomllib | Next: tomllib.TOMLDecodeError
Rel: tomllib.load, tomllib.TOMLDecodeError
Ref: docs.python.org — tomllib.loads
Tags: #public #python3 #stdlib #tomllib
Import
import tomllib
from tomllib import loads
Signature & Overview
tomllib.loads(s: 'str', /, *, parse_float: 'ParseFloat' = <class 'float'>) -> 'dict[str, Any]'
Parse TOML from a string.
Usage
import tomllib
cfg = tomllib.loads('[server]\nport = 8080\ndebug = false\n')
assert cfg == {"server": {"port": 8080, "debug": False}}
Gotchas
- Accepts
stronly (notbytes): Decode bytes with.decode("utf-8")first, or wrap them inio.BytesIOfortomllib.load(). - Dates become native
datetime/date/timeobjects: TOML timestamps parse directly into stdlibdatetimetypes.
REPL Inspect
from tomllib import loads
help(loads)
Linked from
Related notes
- tuts/python3/stdlib_module/tomllib/load Linked here; links to this page; shared tags: #stdlib, #tomllib
- tuts/python3/stdlib_module/tomllib/TOMLDecodeError Linked here; links to this page; shared tags: #stdlib, #tomllib
- tuts/python3/stdlib_module/tomllib Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib