# encoding:UTF-8
from functools importreduce
#map()批处理,使用函数接收一个元素互不影响
#a = list(map(str,[0,1,2,3,4]))
#print(a)
#def p2(x):
# return x^2
#a =map(p2,[1,2,3,4,5,6])
#print(list(a))
#reduce()累积处理 使用函数接收俩个元素,把结果作为下一个元素使用:
#reduce需要import
def my_sum(x,y):
return x+y
#a = reduce(my_sum,[1,2,3,4,5,6])
#print(a)
def Convert_integer(x,y):
return x*10+y
#a = reduce(Convert_integer,[1,2,3,4,5])
#print(a)
def str2num(s):
digits={'0':0,'1':1,'2':2,'3':3}
return digits[s]
#a =reduce(my_sum,map(str2num,['1','2','3']))
# #print(a)
#lambda 用于直接定义函数
a = reduce(lambda x,y: x * 10 + y,map(str2num,['2','1','3']))
print(a)