import save
string = \"\"
with open(\"image.jpg\", \"rb\") as f:
byte = f.read(1)
while byte != b\"\":
byte = f.read(1)
print ((byte))
<
This is one way to get rid of the b''
:
import sys
print(b)
If you want to save the bytes later it's more efficient to read the entire file in one go rather than building a list, like this:
with open('sample.jpg', mode='rb') as fh:
content = fh.read()
with open('out.jpg', mode='wb') as out:
out.write(content)