So i have a binary file - i need all of the bits in that file in a list. I know that using the Rb function when opening the file gets all of the bytes like this:
with open("binaryfile.bin", "rb") as f:
bytes_read = f.read()
for b in bytes_read:
fetch(b)
But i was wondering if there was a way I could get all of the specific bits in this binary file - and put it in a list.
I know python can only do it via bytes. How do I split it up into bits? (i believe there are 8 bits per byte, correct?)
Thanks!
I tried using the rb function but that only works with bytes, not bits.
bin(int.from_bytes(bytes_read, "big"))[2:]. If you want a list of ints, justmap(int, ...)thatfetch(b)supposed to do?