@@ -37,7 +37,8 @@ This module defines the following functions:
37
37
.. function :: load(fp, /, *, parse_float=float)
38
38
39
39
Read a TOML file. The first argument should be a readable and binary file object.
40
- Return a :class: `dict `.
40
+ Return a :class: `dict `. Convert TOML types to Python using this
41
+ :ref: `conversion table <toml-to-py-table >`.
41
42
42
43
*parse_float * will be called with the string of every TOML
43
44
float to be decoded. By default, this is equivalent to ``float(num_str) ``.
@@ -51,8 +52,9 @@ This module defines the following functions:
51
52
52
53
.. function :: loads(s, /, *, parse_float=float)
53
54
54
- Load TOML from a :class: `str ` object. The *parse_float * argument has the
55
- same meaning as in :func: `load `.
55
+ Load TOML from a :class: `str ` object. Return a :class: `dict `. Convert TOML
56
+ types to Python using this :ref: `conversion table <toml-to-py-table >`. The
57
+ *parse_float * argument has the same meaning as in :func: `load `.
56
58
57
59
A :exc: `TOMLDecodeError ` will be raised on an invalid TOML document.
58
60
@@ -84,3 +86,33 @@ Parsing a TOML string::
84
86
"""
85
87
86
88
data = tomllib.loads(toml_str)
89
+
90
+
91
+ Conversion Table
92
+ ----------------
93
+
94
+ .. _toml-to-py-table :
95
+
96
+ +------------------+--------------------------------------------------------------------------------------+
97
+ | TOML | Python |
98
+ +==================+======================================================================================+
99
+ | table | dict |
100
+ +------------------+--------------------------------------------------------------------------------------+
101
+ | string | str |
102
+ +------------------+--------------------------------------------------------------------------------------+
103
+ | integer | int |
104
+ +------------------+--------------------------------------------------------------------------------------+
105
+ | float | float (configurable with *parse_float *) |
106
+ +------------------+--------------------------------------------------------------------------------------+
107
+ | boolean | bool |
108
+ +------------------+--------------------------------------------------------------------------------------+
109
+ | offset date-time | datetime.datetime (``tzinfo `` attribute set to an instance of ``datetime.timezone ``) |
110
+ +------------------+--------------------------------------------------------------------------------------+
111
+ | local date-time | datetime.datetime (``tzinfo `` attribute set to ``None ``) |
112
+ +------------------+--------------------------------------------------------------------------------------+
113
+ | local date | datetime.date |
114
+ +------------------+--------------------------------------------------------------------------------------+
115
+ | local time | datetime.time |
116
+ +------------------+--------------------------------------------------------------------------------------+
117
+ | array | list |
118
+ +------------------+--------------------------------------------------------------------------------------+
0 commit comments