Función bytearray() de Python
Ejemplo
Devuelve una matriz de 4 bytes:
x = bytearray(4)
Definición y uso
La bytearray()
función devuelve un objeto bytearray.
Puede convertir objetos en objetos bytearray, o crear objetos bytearray vacíos del tamaño especificado.
Sintaxis
bytearray(x, encoding, error)
Valores paramétricos
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. |