⇨ MENU ⇨ METHODES ⇨ bytearray ( )
bytearray ( ).translate ( )
⇨ MENU ⇨ METHODES ⇨ bytearray ( )
bytearray ( ).translate ( )
DESCRIPTION.
Retourne un nouveau tableau d'octets, où chaque octet est remplacé par l'octet correspondant dans la table de transformation fournie.
SYNTAXE.
BYA_Texte = tableau.translate ( table )
BYA_Texte = ⇨ variable qui recevra la nouvelle chaine [ optionnel ]
tableau ⇨ tableau d'octets [ OBLIGATOIRE ]
.translate ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
table ⇨ table de cryptage [ OBLIGATOIRE ]
REMARQUES.
tableau doit être un objet de type bytearray ( ) valide.
table est un tableau d'octets de type bytes ( ) ou bytearray ( ).
Voir bytearray.maketrans ( ) pour plus de détails sur la construction d'une table de transformation.
EXEMPLES.
BYT_Cryptage = b"".maketrans ( b"aeiou" , b"12345" )
print ( bytearray ( b"Salut le monde.".translate ( BYT_Cryptage ) ) ) retourne bytearray(b'S1l5t l2 m4nd2.')
print ( type ( BYT_Cryptage ) ) retourne <class 'bytes'>
print ( BYT_Cryptage ) retourne
b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`1bcd2fgh3jklmn4pqrst5vwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
Le tableau d'octets retourné contient les 256 valeurs possibles pour les éléments des bytes ( ) ou bytearray ( ), mais les valeurs valeur a, e, i, o et u ont été remplacées par 1, 2, 3, 4 et 5.
Votre aide est précieuse pour améliorer ce site, alors n'hésitez pas à faire part de
Dans la LOGITHEQUE de MON PYTHON PAS A PAS
vous trouvez des suggestions de projets simples et classiques pour
ooo
TESTER - DÉCOUVRIR - PRATIQUER - APPROFONDIR - EXPLORER
ooo
la programmation récréative avec le langage PYTHON 3
avec un exemple de résolution à télécharger pour vous inspirer.