How print binary data on screen

Ehsen Siraj ehsensiraj at gmail.com
Tue Mar 17 14:28:26 EDT 2009


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
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File 
"/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/py/shell.py", 
line 1160, in writeOut
    self.write(text)
  File 
"/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/py/shell.py", 
line 950, in write
    self.AddText(text)
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/stc.py", 
line 1425, in AddText
    return _stc.StyledTextCtrl_AddText(*args, **kwargs)
  File "/usr/lib/python2.5/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: 
unexpected code byte

please help me how i fix this thing.





More information about the Python-list mailing list