Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,14 @@ expression support in the :mod:`re` module).
>>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})
'XY123'

For example, removing vowels using :meth:`str.maketrans`:

.. doctest::

>>> table = str.maketrans('', '', 'aeiou')
>>> 'hello world'.translate(table)
'hll wrld'

See also the :mod:`codecs` module for a more flexible approach to custom
character mappings.

Expand Down
Loading