8000 [3.14] gh-106318: Add example for `str.encode()` (GH-134520) (#135457) · python/cpython@f22aae1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f22aae1

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

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& 73A0 gt;` 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)
0