0

I have a string of 0's and 1's, e.g. [011101110] I want to write each one as a bit to a file, so the space of the file will be 1 byte. instead of 8 bytes as each digit is written as it's own character.

I'm currently using this method but it can't seem to work.

with open(input_file.name + ".chris", "wb") as output_file:
    binary = bytearray(compressed.encode())
    output_file.write(binary)
    output_file.close()

compressed variable is the string of 0's and 1's

0 Answers0