Name
translate
Synopsis
s
.translate(table
,deletechars
='')
Returns a copy of s
where all characters
occurring in string deletechars
are
removed, and the remaining characters are mapped through
translation-table table
. When
s
is a plain string,
table
must be a plain string of length
256. When s
is a Unicode string,
table
must be a Unicode string of length
65536. Each character c
is mapped to
character
table
[ord(
c
)]
.
A plain-string table
is most often built
using function string.maketrans
, covered later.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.