Here's what I have:
import pickle
data = open(r'C:\pickl e_data.txt', 'w')
image = open(r'C:\peakh ell.jpg')
pickle.Pickler( data)
data.dump(image )
data.close()
image.close()
First off, I'm not sure the second line is the way to do that. But my
main problem is I don't know how to define the steps when pickling an
object. How do you first create the object? Does it return a value? I tried:
pickler = pickle.Pickler( data)
pickle.Pickler( data)
Then I tried:
pickler.dump(im age)
data.dump(image )
Basically, I'm just confused about all the syntax involved. Which
objects do I operate on, and when? I can't find these answers in the
documentation or in the interactive help, because I don't see any examples.
Furthermore, I get this error every time:
Traceback (most recent call last):
File "C:\Documen ts and Settings\jsaler 01.TUFTS\My
Documents\Pytho n24\myscripts\c hallenges\pickl e.py", line 3, in -toplevel-
import pickle
File "C:\Documen ts and Settings\jsaler 01.TUFTS\My
Documents\Pytho n24\myscripts\c hallenges\pickl e.py", line 7, in -toplevel-
pickle.Pickler( data)
AttributeError: 'module' object has no attribute 'Pickler'
So that makes me really confused, because I must have the syntax totally
wrong if it can't even get past the initial creation of a pickler object.
import pickle
data = open(r'C:\pickl e_data.txt', 'w')
image = open(r'C:\peakh ell.jpg')
pickle.Pickler( data)
data.dump(image )
data.close()
image.close()
First off, I'm not sure the second line is the way to do that. But my
main problem is I don't know how to define the steps when pickling an
object. How do you first create the object? Does it return a value? I tried:
pickler = pickle.Pickler( data)
pickle.Pickler( data)
Then I tried:
pickler.dump(im age)
data.dump(image )
Basically, I'm just confused about all the syntax involved. Which
objects do I operate on, and when? I can't find these answers in the
documentation or in the interactive help, because I don't see any examples.
Furthermore, I get this error every time:
Traceback (most recent call last):
File "C:\Documen ts and Settings\jsaler 01.TUFTS\My
Documents\Pytho n24\myscripts\c hallenges\pickl e.py", line 3, in -toplevel-
import pickle
File "C:\Documen ts and Settings\jsaler 01.TUFTS\My
Documents\Pytho n24\myscripts\c hallenges\pickl e.py", line 7, in -toplevel-
pickle.Pickler( data)
AttributeError: 'module' object has no attribute 'Pickler'
So that makes me really confused, because I must have the syntax totally
wrong if it can't even get past the initial creation of a pickler object.
Comment