Skip to content

Commit c036e59

Browse files
blaisephugovk
authored andcommitted
pythongh-106318: Add example for str.encode() (pythonGH-134520)
(cherry picked from commit 2734595) Co-authored-by: Blaise Pabon <blaise@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 9a10b73 commit c036e59

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

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)