MapReduce编程模型:
- Map:映射过程
- Reduce:合并过程
import operator from functools import reduce # 需要处理的数据 lst = [ "Tom", "Jack", "Mimi", "Jiji", "GoodMan" ] # map过程:对每个数据进行处理,映射为字符串长度 lst = map(len, lst) print(lst) # <map object at 0x101b43c18> # reduce过程:对所有map处理过的数据进行汇总 result = reduce(operator.add, lst) print(result) # 22