Python bytearray() Funzione
Esempio
Restituisce un array di 4 byte:
x = bytearray(4)
Definizione e utilizzo
La bytearray()
funzione restituisce un oggetto bytearray.
Può convertire oggetti in oggetti bytearray o creare oggetti bytearray vuoti della dimensione specificata.
Sintassi
bytearray(x, encoding, error)
Valori dei parametri
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. |