efryevt
asked on
Editing bytes in Python
Preface: I am extremely new to Python, so this question may be asked poorly.
I am working with an API that returns a buffer which I need to edit and then pass back into another function. In the API documentation, buffer is shown as the return data type. Which brings me to my first question: what exactly is a buffer datatype?
If I treat the buffer as a bytearray and edit it, I get the following error:
'str' object does not support item assignment
Googling led me to believe the buffer may actually be a bytes datatype. If this is indeed the case, how can I edit the nth byte in the buffer of bytes?
I am working with an API that returns a buffer which I need to edit and then pass back into another function. In the API documentation, buffer is shown as the return data type. Which brings me to my first question: what exactly is a buffer datatype?
If I treat the buffer as a bytearray and edit it, I get the following error:
'str' object does not support item assignment
Googling led me to believe the buffer may actually be a bytes datatype. If this is indeed the case, how can I edit the nth byte in the buffer of bytes?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have recommended this question be closed as follows:
Accept: pepr (https:#a41018051)
If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
suhasbharadwaj
Experts-Exchange Cleanup Volunteer