Skip to content

Commit 7843b3a

Browse files
committed
Add example for str.encode()
WIP to fix python#106318
1 parent 09e72cf commit 7843b3a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Doc/library/stdtypes.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,9 +1817,15 @@ expression support in the :mod:`re` module).
18171817
See :ref:`error-handlers` for details.
18181818

18191819
For performance reasons, the value of *errors* is not checked for validity
1820-
unless an encoding error actually occurs,
1821-
:ref:`devmode` is enabled
1822-
or a :ref:`debug build <debug-build>` is used.
1820+
unless an encoding error actually occurs, :ref:`devmode` is enabled or a :ref:`debug build <debug-build>` is used.
1821+
For example::
1822+
1823+
>>> encoded_str_to_byte = 'Python'.encode()
1824+
>>> type(encoded_str_to_byte)
1825+
<class 'bytes'>
1826+
>>> encoded_str_to_byte
1827+
b'Python'
1828+
18231829

18241830
.. versionchanged:: 3.1
18251831
Added support for keyword arguments.

0 commit comments

Comments
 (0)