2021年1月22日星期五

How to write string to memoryview?

I want to write a bytearray type into a memoryview type. What I tried:

my_memory_view = memoryview(b'hello')  new_byte_string = bytearray(b'world')  my_memory_view = new_byte_string  

but it returned:

AttributeError: can't set attribute  

I know that it is possible to write into memoryview via:

my_memory_view[0] = 12  #Changes first byte  

Is there a way to insert the values of the bytearray automatically into memoryview?

https://stackoverflow.com/questions/65854002/how-to-write-string-to-memoryview January 23, 2021 at 07:12AM

没有评论:

发表评论