2

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 ?

MicrosoctCprog
  • 460
  • 1
  • 3
  • 23

1 Answers1

1

byte item assignment with bytearray

arr = b'12345678'
arr = bytearray(arr)
arr[2:] = b'fff'
Johnny
  • 687
  • 1
  • 6
  • 22