gh-106318: Add example for str.encode() (#134520)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Blaise Pabon 2025-06-13 11:32:07 +00:00 committed by GitHub
parent 747d390045
commit 273459562e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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.