Welcome

sampleqa.in tutorials, Python Programming  tutorial,Python Classes

Python 3 Tutorial


Python bytes , bytearray


Python supports two other types called bytes and bytearray , Which holds only bytes ranging from 0 to 255.

  • bytes
  •      bytes are immutable sequence of single bytes. Ther are similar to string objects(str), and you can also think of them as immutable array of bytes.

  • bytearray
  •      bytearray is mutable array of bytes, values range from 0 to 255. This is also similar to string objects(s), string supports unicodes, where as bytearray supports single byte data, i.e each element size is single byte. bytearray supports append, update, remove methods, because it can shrink or resize.

Note: bytes and bytearray both are array data structure, array's require contiguoes memory locations.

bytes

bytearray

ADS