error loading files containing nullbytes w/ urllib?

vincent wehren v.wehren at home.nl
Thu Jun 19 12:33:18 EDT 2003


"Luther Blisset" <fraqutal at gmx.de> schrieb im Newsbeitrag
news:d582c617.0306190811.d556599 at posting.google.com...
> 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_b
ush_junior_150.jpg')
> img = pic.read()
> pic.close()
> f = open('gwb.jpg','w')

try:
f = open('gwb.jpg','wb')

HTH
Vincent Wehren


> 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