On Tue, Oct 12, 2010 at 1:35 PM, Roelof Wobben <rwob...@hotmail.com> 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 ? > I have heard of pickle, but never used it. I looked it up in Learning Python (O'Reilley p 236). The example they give shows that you need to pickle your object, and put it in a file with pickle(dump(D,F) where D is a dictionary in the example and F is a file object. You then can retrieve it with pickle.load(F). The thing you are trying to load is a file that was a copy of the contents of the url. It is html, and not 'pickled' I think you are missing a line or two of code from your example tutorial > > Roelof > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor