The Python Maketrans () method is used to create a conversion table of character mappings, for the simplest invocation of two parameters, the first argument is a string that represents the character that needs to be converted, and the second argument is the target of the string representation of the transformation.
Note: the length of the two strings must be the same for the one by one corresponding relationship.
- Intab-A string that consists of characters in the string to be substituted.
- Outtab--a string corresponding to the mapped character.
The From string import Maketrans # references the Maketrans function. Intab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Outtab = "Cdefghijklmnopqrstuvwxyzab" Trantab = Maketrans (intab, outtab) str = "G FMNC WMS Bgblr RPYLQJYRC gr ZW fylb. RFYRQ Ufyr AMKNSRCPQ ypc DMP. Bmgle GR GL ZW fylb GQ glcddgagclr ylb rfyr ' q UFW rfgq rcvr GQ QM Jmle. Sqgle QRPGLE.KYICRPYLQ () GQ PCAMKKCLBCB. LMU ynnjw ml RFC spj. " Print str.translate (trantab);
Python-string.maketrans