Fonction Python bytearray()
Exemple
Renvoie un tableau de 4 octets :
x = bytearray(4)
Définition et utilisation
La bytearray()
fonction renvoie un objet bytearray.
Il peut convertir des objets en objets bytearray ou créer un objet bytearray vide de la taille spécifiée.
Syntaxe
bytearray(x, encoding, error)
Valeurs des paramètres
Parameter | Description |
---|---|
x | A source to use when creating the bytearray object. If it is an integer, an empty bytearray object of the specified size will be created. If it is a String, make sure you specify the encoding of the source. |
encoding | The encoding of the string |
error | Specifies what to do if the encoding fails. |