Funkce python bytearray().
Příklad
Vrátí pole 4 bajtů:
x = bytearray(4)
Definice a použití
Funkce bytearray()
vrací objekt bytearray.
Může převádět objekty na objekty byearray nebo vytvořit prázdný objekt typu byearray zadané velikosti.
Syntax
bytearray(x, encoding, error)
Hodnoty parametrů
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. |