Python 2与3:Lambda运算符

plo*_*lot 5 python python-3.x

lambda函数在Python 2和3之间的工作方式是否发生了变化?我在python 2中运行了代码,但工作正常,但在python 3中却失败了,为了尝试利用第三方模块,我试图将代码移植到其中。

pos_io_tagged = map(lambda ((word, pos_tag), io_tag):
    (word, pos_tag, io_tag), zip(zip(words, pos_tags), io_tags))
Run Code Online (Sandbox Code Playgroud)

我已经研究#2多个问题,并宣读了几个如文章,但仍然无法找到答案。我可以查看任何资源吗?

A.J*_*pal 5

您的问题是您()在lambda表达式中使用了括号,这会使它感到困惑。请尝试以下操作:

pos_io_tagged = map(lambda word, pos_tag, io_tag:
    (word, pos_tag, io_tag), zip(zip(words, pos_tags), io_tags))
Run Code Online (Sandbox Code Playgroud)

这里了解更多信息。