Função bytearray() do Python
Exemplo
Retorna um array de 4 bytes:
x = bytearray(4)
Definição e uso
A bytearray()
função retorna um objeto bytearray.
Ele pode converter objetos em objetos bytearray ou criar um objeto bytearray vazio do tamanho especificado.
Sintaxe
bytearray(x, encoding, error)
Valores de parâmetro
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. |