Wednesday, 1 December 2021

Python: bytearray: Return mutable array of bytes

‘bytearray’ method take an object and return a mutable bytes array.

 

Signature

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

 

byte_array_1.py

even_numbers = [2, 4, 6, 8]

byte_array = bytearray(even_numbers)
print(byte_array)

 

Output

bytearray(b'\x02\x04\x06\x08')

 

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment