Input/output utirites of a bit-basis file
Project description
# bitio
Input/output utirites of bit basis file
## How to use
```py
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 same
```py
f.write_bits(bits, count)
for i in range(count-1, -1, -1):
if bits & (1 << i):
f.write(1)
else:
f.write(0)
```
othe interface
```py
l = []
wrapper = ByteWrapper(l.append)
f = bit_wrap(wrapper, "w")
f.write_bits(0b110000101, 10)
print l # ["a"]
f.close()
print l # ["a", "@"]
```
Input/output utirites of bit basis file
## How to use
```py
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 same
```py
f.write_bits(bits, count)
for i in range(count-1, -1, -1):
if bits & (1 << i):
f.write(1)
else:
f.write(0)
```
othe interface
```py
l = []
wrapper = ByteWrapper(l.append)
f = bit_wrap(wrapper, "w")
f.write_bits(0b110000101, 10)
print l # ["a"]
f.close()
print l # ["a", "@"]
```
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.2.tar.gz
(2.1 kB
view details)
File details
Details for the file bitio-0.2.tar.gz
.
File metadata
- Download URL: bitio-0.2.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfdde32d0064eecc13ee2a0cc5da329bff05ec702460c67ece05ed4669570637 |
|
MD5 | d5578bf130f093486c30450784ce156e |
|
BLAKE2b-256 | 9de1206fa6591bf465316849476e2628d35fddfb7b89d0cd70ea2fa90e25388f |