error loading files containing nullbytes w/ urllib?

Luther Blisset fraqutal at gmx.de
Thu Jun 19 12:11:00 EDT 2003


When I try to load a file from a server which contains nullbytes, I
get back a corrupted file where all null bytes are converted to
spaces.

When I save the image with a webbrowser I get a normal .jpg with a
length of 4.545 bytes.

When I do that...

import urllib
pic = urllib.urlopen('http://news.bbc.co.uk/olmedia/195000/images/_198996_george_bush_junior_150.jpg')
img = pic.read()
pic.close()
f = open('gwb.jpg','w')
f.write(img)
f.close()

... I get a file with a size of 4565 bytes and all null bytes are
converted to spaces.
What am I doing wrong???

regards,
frq.




More information about the Python-list mailing list