PyDocs

Nav

Python Runtime Services

str.maketrans

builtins

staticmethod of str
  • str.maketrans(dict, /)
  • str.maketrans(from, to, remove='', /)
Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping
Unicode ordinals (integers) or characters to Unicode ordinals,
strings or None.  Character keys will be then converted to ordinals.
If there are two arguments, they must be strings of equal length,
and in the resulting dictionary, each character in x will be mapped
to the character at the same position in y.  If there is a third
argument, it must be a string, whose characters will be mapped to
None in the result.
Changed in 3.15
  • 3.15: dict can now be a frozendict.
0 Examples
No examples for builtins/str.maketrans.
See Also
No see-alsos for builtins/str.maketrans
0 Notes
No notes for str.maketrans