⇨ MENU ⇨ METHODES ⇨ bytearray ( )
bytearray ( ).rstrip ( )
⇨ MENU ⇨ METHODES ⇨ bytearray ( )
bytearray ( ).rstrip ( )
DESCRIPTION.
Retourne un nouveau tableau d'octets en supprimant certains octets, s'ils existent, à droite du tableau d'octets de référence.
SYNTAXE.
BYA_Tableau = tableau.rstrip ( modele )
BYA_Tableau = ⇨ variable qui recevra la nouvelle chaine [ optionnel ]
tableau ⇨ tableau d'octets [ OBLIGATOIRE ]
.rstrip ( ) ⇨ appel de la méthode [ OBLIGATOIRE ]
modele ⇨ octets à supprimer [ optionnel ]
REMARQUES.
tableau doit être un objet de type bytearray ( ) valide.
modele doit être un tableau d'octets de type bytes ( ) ou bytearray ( ). Si modele contient plusieurs octets, c'est bien la présence, à la fin de tableau, de ces octets qui sont supprimés et non la combinaison complète de ces octets. Par défaut, modele est b" ".
Bien que tableau soit du type bytearray ( ), un tableau d'octets muable, la méthode bytearray ( ).rstrip ( ) ne modifie pas l'objet appelant, mais crée et retourne un nouveau objet bytearray ( ) avec les modifications demandées.
EXEMPLES.
print ( bytearray ( "Mon Python à moi. " , "utf-8" ).rstrip ( ) ) retourne bytearray(b'Mon Python \xc3\xa0 moi.')
BYA_Titre = bytearray ( "Mon Python à moi" , "utf-8" )
print ( BYA_Titre.rstrip ( b"i" ) ) retourne bytearray(b'Mon Python \xc3\xa0 mo')
print ( BYA_Titre.rstrip ( b"I" ) ) retourne bytearray(b'Mon Python \xc3\xa0 moi')
print ( BYA_Titre.rstrip ( b"Python" ) ) retourne bytearray(b'Mon Python \xc3\xa0 moi')
BYA_Test = bytearray ( b"test TEST test" )
print ( BYA_Test.rstrip ( b"test" ) ) retourne bytearray(b'test TEST ')
print ( BYA_Test.rstrip ( b"tes" ) ) retourne bytearray(b'test TEST ')
print ( BYA_Test.rstrip ( b"est" ) ) retourne bytearray(b'test TEST ')
print ( BYA_Test.rstrip ( b"set" ) ) retourne bytearray(b'test TEST ')
print ( BYA_Test.rstrip ( b"EST" ) ) retourne bytearray(b'test TEST test')
BYA_Vidage = bytearray ( b"test" )
BYA_Test = bytearray ( b"test TEST test" )
BYA_Propre = BYA_Test.rstrip ( BYA_Vidage )
print ( BYA_Test.rstrip ( BYA_Vidage ) ) retourne bytearray(b'test TEST ')
print ( BYA_Propre ) retourne bytearray(b'test TEST ')
print ( BYA_Test ) retourne bytearray(b'test TEST test')
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.