Change byte array buffer with python

Viewed 957

I have bytes array in Python that I want to change some value by index

arr =b'12345678'
arr[2:] =b'fff'

But I got error TypeError: 'bytes' object does not support item assignment

Why is that ? how to do that ?

1 Answers

byte item assignment with bytearray

arr = b'12345678'
arr = bytearray(arr)
arr[2:] = b'fff'
Related