dill: python to solve the "AttributeError: Can not pickle local object" and the problem can not pickle lambda functions

the python pickle is used to serialize objects handy tool, but requires pickle incoming object is not an internal class can not be a function of lambda.

For example, try to pickle the inner class:

The results will complain AttributeError: Can't pickle local object.

This problem can be solved by third-party libraries dill: ( https://pypi.org/project/dill/ )

result:

dill addition to the standard type of process may be treated pickle:

Ah, or good use.

(Further built library python pickle shelve also used to do back-end, it is not the default classes and Handling lambda functions.)

Guess you like

Origin www.cnblogs.com/dylanchu/p/11275817.html