Python: saving objects and using pickle. extension of filename
You could use any filename
, but as an FYI it's common to use ".p" (for obvious reasons).
pickle.dump( favorite_color, open( "save.p", "wb" ) )
Read: UsingPickle
One more thing you should pay attention to:
you should used binary mode with operation of pickling files. So 'w' should be 'wb'.
Depends on what you want to do with the file.
filename
should be sufficient.
And don't use object
as an identifier. It shadows the builtin object
.