how to return represent binary 1 and 0 using BitArray in python

59 views Asked by At

i have audio file and i was represent the file with 1 and 0 using bitarray. but i want to get the result. when i return the variable, the result i got is not same as the text file was made. so how to return the result?

here's my code:

def readbinary(audio):
    # audio have my location file
    b=BitArray(bytes=open(audio,'rb').read())

    # Store result
    with open('txt/'+'binary.txt', 'w') as file1: 
        file1.write(b.bin) #the result from text file : 000000000000000000000000000110000110011001110100011110010111000001100100011000010111001101101000000000000000000000000000000000000110100101110011011011110011011001101101011100000011010000110001000000000000000000000010011000000110110101101111011011110111011000000000000000000000000001101100011011

    return b # the result from return : 0x0000001866747970646173680000000069736f366d703431000002606d6f6f760000006c6d76686400000000dea15aa0dea15aa00000a

i need the result 000000000000000000000000000110000110011001110100011110010111000001100100011000010111001101101000000000000000000000000000000000000110100101110011011011110011011001101101011100000011010000110001000000000000000000000010011000000110110101101111011011110111011000000000000000000000000001101100011011 to next stage

0

There are 0 answers