bytes type is a sequence type. bytes are represented with the b'…' literal. bytes objects are read-only: foo = b'Foo' print(foo[0]) # 70 foo[0] = 102
bytearray allows to modify individual bytes. hex() returns a hexadecimal representation of the bytes object: >>> b'ABC'.hex() '414243'
str. Compare with binascii.hexlify(). bytes built-in function .encode() method of the string object. bytes.