BitsIO: A bit stream I/O class
Installing
Use pip to install BitsIO:
pip install bitsio
Usage
Example for reading:
from io import BytesIO
from bitsio import BitsIO
bytesio = BytesIO(b'HELLO')
bitsio = BitsIO(bytesio, bitorder='big')
for _ in range(1, 5):
print(chr(bitsio.read(8)))
Example for writing:
from bitsio import BitsIO
test_input = 'HELLO'
with open('hello.txt', 'wb') as f:
bitsio = BitsIO(f, bitorder='big')
for s in test_input:
bitsio.write(ord(s), 8)
Example test running:
python -m unittest discover ./tests/
Copyright (c) 2018 Minoru Hiki. All rights reserved.