How print binary data on screen
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Tue Mar 17 14:45:45 EDT 2009
Ehsen Siraj wrote:
> I am trying to print binary data on screen but I got the following error.
>
> f = open('/home/ehsen/1.mp3','rb')
> g = f.read()
> print g
[...]
> UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0:
> unexpected code byte
>
> please help me how i fix this thing.
One way of printing it would be:
print g.encode("hex")
but you don't say what you wanted to accomplish.
"printing" a mp3 file to the screen doesn't make much sense.
--irmen
More information about the Python-list
mailing list