Python bytearray() Funksie
Voorbeeld
Wys 'n skikking van 4 grepe:
x = bytearray(4)
Definisie en gebruik
Die bytearray()
funksie gee 'n bytearray-voorwerp terug.
Dit kan voorwerpe omskep in bytearray-objekte, of leë bytearray-voorwerpe van die gespesifiseerde grootte skep.
Sintaksis
bytearray(x, encoding, error)
Parameterwaardes
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. |