Difference between bytes and bytearray in Python

Profile picture for user devanshi.srivastava
Submitted by devanshi.srivastava on


  • It returns the "bytes" Object. 
  • It is immutable. (cannot be modified once declared).
  • It is the sequence of a small integer whose range is from 0<=x<256.
bytes([source [, encoding [, errors]]])


  • This method returns the bytearray object (i.e. array of given bytes).
  • It is a mutable(can be modified) sequence of bytes.
  • It is the sequence of integers in the range 0 <= x < 256.
bytearray([source[,encoding [,errors]]])