python的怎么打印map和reduce结果

如题所述

第1个回答  2016-09-26

map先转换成list再print就行了。

print(list(map(lambda x: x + 1, [1, 2, 3])))


reduce是直接出结果的。

from functools import reduce
print(reduce(lambda x, y: x + y, [1, 2, 3]))

本回答被提问者采纳