How to get binary data from Python's ByteIO

Use the getvalue() function of the BytesIO instance. Example:

bytesio_example.py
#!/usr/bin/env python3
from io import BytesIO

myio = BytesIO()
myio.write(b"Test 123")

print(myio.getvalue()) # Prints b'Test 123'

 


Check out similar posts by category: Python