Answers for "why to use pickle in python"

8

read pickle file

with open('filename', 'rb') as f:
    x = pickle.load(f)
Posted by: Guest on August-26-2020
1

TypeError: cannot pickle 'module' object

You can't pickle an entire module, you'll have to break the module up
into the attributes you need, for example this problem occured to me when
I was trying to multiprocess opencv2, instead of sending in the whole
module I just sent in the attributes: waitKey, imshow, imread and
destroyAllWindows, so the system only has to pickle those functions
rather than the whole module which worked out.
Posted by: Guest on March-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language