[Tutor] pickle problem

Adam Bark adam.jtm30 at gmail.com
Tue Oct 12 22:08:12 CEST 2010


On 12/10/10 18:35, Roelof Wobben wrote:
> Hello,
>
> I have this code :
>
> import urllib
> import pickle
>
> image = urllib.URLopener()
> image.retrieve("http://www.pythonchallenge.com/pc/def/peak.html","banner.p" )
> plaatje = open("banner.p", "rb")
> plaatje2 = pickle.load(plaatje)
>
> But it gives this output :
>
> Traceback (most recent call last):
>    File "C:\Users\wobben\workspace\oefeningen\src\test2.py", line 7, in<module>
>      plaatje2 = pickle.load(plaatje)
>    File "C:\Python27\lib\pickle.py", line 1378, in load
>      return Unpickler(file).load()
>    File "C:\Python27\lib\pickle.py", line 858, in load
>      dispatch[key](self)
> KeyError: '<'
>
>
> What does this mean ?
>    
It means that it's trying to access a sequence with the key '<' but it's 
not working. It looks like the problem is you're trying to open 
peak.html as a pickle but it is actually an html file.

HTH,
Adam.


More information about the Tutor mailing list