Skip to content

Commit db408a4

Browse files
miss-islingtonblaisephugovk
authored
[3.13] gh-106318: Add example for str.encode() (GH-134520) (#135458)
Co-authored-by: Blaise Pabon <blaise@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 9a10b73 commit db408a4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,14 @@ expression support in the :mod:`re` module).
17051705
unless an encoding error actually occurs,
17061706
:ref:`devmode` is enabled
17071707
or a :ref:`debug build <debug-build>` is used.
1708+
For example::
1709+
1710+
>>> encoded_str_to_bytes = 'Python'.encode()
1711+
>>> type(encoded_str_to_bytes)
1712+
<class 'bytes'>
1713+
>>> encoded_str_to_bytes
1714+
b'Python'
1715+
17081716

17091717
.. versionchanged:: 3.1
17101718
Added support for keyword arguments.

0 commit comments

Comments
 (0)