]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-106318: Add example for `str.encode()` (GH-134520) (#135457)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 13 Jun 2025 11:46:06 +0000 (13:46 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Jun 2025 11:46:06 +0000 (14:46 +0300)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Doc/library/stdtypes.rst

index b75e5ceecf874e8c6efa484d5d1f66180c131190..4854a2c077bb2833b93f9f4ce9af92f20cbc5016 100644 (file)
@@ -1841,6 +1841,14 @@ expression support in the :mod:`re` module).
    unless an encoding error actually occurs,
    :ref:`devmode` is enabled
    or a :ref:`debug build <debug-build>` is used.
+   For example::
+
+      >>> encoded_str_to_bytes = 'Python'.encode()
+      >>> type(encoded_str_to_bytes)
+      <class 'bytes'>
+      >>> encoded_str_to_bytes
+      b'Python'
+
 
    .. versionchanged:: 3.1
       Added support for keyword arguments.