Python bytearray() Fungsi
Contoh
Kembalikan array 4 byte:
x = bytearray(4)
Definisi dan Penggunaan
Fungsi bytearray()
mengembalikan objek bytearray.
Itu dapat mengubah objek menjadi objek bytearray, atau membuat objek bytearray kosong dengan ukuran yang ditentukan.
Sintaksis
bytearray(x, encoding, error)
Nilai Parameter
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. |