本文介绍了带有lambdas的python泡菜对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何腌制包含lambda的python对象?

How can I pickle a python object which contains lambdas?

Can't pickle local object 'BaseDiscretizer.__init__.<locals>.<lambda>'

是我尝试腌制 https://github上的错误.com/marcotcr/lime/blob/97a1e2d7c1adf7b0c4f0d3b3e9b15f6197b75c5d/lime/discretize.py 腌制 https://github.com/marcotcr/lime/blob/2703bcdcddd135947fe74e99cc270aa4fac3263a/lime/lime_tabular.py#L88 LimeTabularExplainer

is the error I get when trying to pickle https://github.com/marcotcr/lime/blob/97a1e2d7c1adf7b0c4f0d3b3e9b15f6197b75c5d/lime/discretize.py when pickling the https://github.com/marcotcr/lime/blob/2703bcdcddd135947fe74e99cc270aa4fac3263a/lime/lime_tabular.py#L88 LimeTabularExplainer

推荐答案

标准pickle模块无法序列化lambda,但是有一个名为 dill 支持它们.

The standard pickle module cannot serialize lambdas, but there is a third party package called dill which supports them.

这篇关于带有lambdas的python泡菜对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 19:32