How to convert memoryview to bytes?

DrWhooze :

How do I convert a Python memoryview to bytes?

For example:

>>> convert(memoryview(b"test"))
b"test"
Bharel :

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related