I read the binary file (ogg vorbis) and extract several packages for further processing. These packages are python byte objects, and we will use them to read using the read (n_bytes) method. Now my code looks something like this:
packet = b'abcd' some_value = packet[0:2] other_value = packet[2:4]
And I want something like this:
packet = b'abcd' some_value = packet.read(2) other_value = packet.read(2)
How to create a readable stream from a byte object?
source share