Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python bytearray() Function

Python bytearray() Function

Python built-in function Python built-in function


Description

bytearray() The method returns a new byte array. The elements in this array are mutable, and the value of each element is in the range: 0 <= x < 256.

Syntax

bytearray() Method Syntax:


class bytearray([source[, encoding[, errors]]])

Parameters

Return Value

Returns a new byte array.

Example

The following examples show the use of bytearray():

bytearray

(

)

bytearray

(

b

'

'

)

bytearray

(

[

1

,

2

,

3

]

)

bytearray

(

b

'

\x

01

\x

02

\x

03

'

)

bytearray

(

'

runoob

'

,

'

utf-8

'

)

bytearray

(

b

'

runoob

'

)

Python built-in function Python built-in function