How do I convert a Python memoryview to bytes?
For example:
>>> convert(memoryview(b"test"))
b"test"
Python's memoryview has a tobytes()
method that allows you to do just that. You're also able to call bytes()
on the object.
Keep in mind that converting a memoryview object to bytes copies the data, and you're able to use memoryview in most places either way. I wouldn't suggest you to convert.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With