+ 1
What is pickle in python? In which scenarios can this feature of python come handy?
3 odpowiedzi
+ 1
mostly, pickle used for serializing and de-serializing. by that I mean converting an object to byte stream and vice versa. but the easiest way you can use it is in a scenario where you want to store a python object like dict or list in a file and restore it. for this purpose you can open a file as binary and dump the object to file. fo restore the object you just need to use load method of pickle library. very easy and handy.
+ 1
@ Srn mrf ...so should the file always be binary?
+ 1
afaik yes. it should. bw mode for dumping object to file and rw mode to restore it from file.