0

I have a problem and I searched a lot and I didn't found an answer.

I read from file as example : "video.mp4" by binary I get as an example : b'\x00\x02\x1a\x00' (binary list) I saved it as string in file : b'\x00\x02\x1a\x00' (string)

I read it again as string : "b'\x00\x02\x1a\x00" (string) I want to convert it again to binary, but no result !!

sometimes I get it like this b"b'\x00\x02\x1a\x00"'

Any answer ??

Oh sorry, here i made simple code because the original is messed up

#!/usr/bin/python

FILE = open("video.mp4", "rb")
FILE2 = open("video", "w")
chunk = FILE.read(8)
FILE2.write(str(chunk))
FILE.close()
FILE2.close()

FILE = open("video", "r")
line = FILE.readline()
print(line)
print(line == str(chunk))
FILE.close()

FILE = open("video_binary", "wb")
FILE.write(line) # Here I want line to convert to binary
FILE.close()

But it same thing

XSC
  • 1
  • 3
  • 1
    Please show the code you've written to read the binary data and write it to another file. It's impossible to tell you what you might be doing incorrectly if we can't see what you're doing at all. – Woodford May 24 '21 at 22:52
  • oh sorry now I added it – XSC May 24 '21 at 23:08

0 Answers0