How can I use the readinto() method call to an offset inside a bytearray, in the same way that struct.unpack_from works?
How can I use the readinto() method call to an offset inside a bytearray
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use a
memoryviewto do the job. For example:Assuming that
iObject.readinto(...)reads the bytes 1, 2, 3, 4, and 5 then this code prints:You can also use the
memoryviewobject withstruct.unpack_fromandstruct.pack_into. For example:This code prints