0

I want to be able to get a file(not just text files, I mean video files, word files, exe files etc...) and read its data in python. Then , I want to convert it to pure binary (1s and 0s) and then be able to decode that too.

I have tried just reading the file with

with open('a.mp4', 'rb') as f:
    ab = f.read()

and it seemed to work, but my function of

def toBinary(a):
  l,m=[],[]
  for i in a:
    l.append(ord(i))
  for i in l:
    m.append(int(bin(i)[2:]))
  return m

does not work on it, because I think ord() only works on text??? Not really sure

0 Answers0