Input/output utilities of a bit-basis file
Project description
bitio
Utilities to read or write files by bit or bits
How to use
from bitio import bit_open
f = bit_open(file_name, "r")
x = f.read() # return 1 or 0
x = f.read_bits(count) # return int
f = bit_open(file_name, "w")
f.write(bit) # write 1 if bit else 0
f.write_bits(bits, count) # write 'count bits'
f.close()
These are the same
f.write_bits(bits, count)
for i in range(count-1, -1, -1):
if bits & (1 << i):
f.write(1)
else:
f.write(0)
Another interface
l = []
wrapper = ByteWrapper(l.append)
f = bit_wrap(wrapper, "w")
f.write_bits(0b110000101, 10)
print(l) # [b"a"]
f.close()
print(l) # [b"a", b"@"]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bitio-0.3.0.tar.gz
(2.6 kB
view details)
File details
Details for the file bitio-0.3.0.tar.gz
.
File metadata
- Download URL: bitio-0.3.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75e36e0ea1bef150213d8d8f01d55e45562181ef2d6febc9e56d4f52d9d40a9f |
|
MD5 | 0be7d6a84b5ebde55ff8ef1ff78ce67c |
|
BLAKE2b-256 | 1d27e6c59bc77c5445e07d749bf9d17ca0e055852bb6c0d8fbaeebaf32d25840 |