Skip to content

Commit 2734595

Browse files
blaisephugovk
andauthored
gh-106318: Add example for str.encode() (#134520)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 747d390 commit 2734595

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
@@ -1841,6 +1841,14 @@ expression support in the :mod:`re` module).
18411841
unless an encoding error actually occurs,
18421842
:ref:`devmode` is enabled
18431843
or a :ref:`debug build <debug-build>` is used.
1844+
For example::
1845+
1846+
>>> encoded_str_to_bytes = 'Python'.encode()
1847+
>>> type(encoded_str_to_bytes)
1848+
<class 'bytes'>
1849+
>>> encoded_str_to_bytes
1850+
b'Python'
1851+
18441852

18451853
.. versionchanged:: 3.1
18461854
Added support for keyword arguments.

0 commit comments

Comments
 (0)