#1.匿名函数标签:内置,函数,zip,reduce,常见,list,print,lambda From: https://www.cnblogs.com/lhg37927/p/16846380.html
# lambda 变量名: 返回值
# 2常见内置函数
ll = map(lambda x:x**2, [x for x in range(10) if x%2 == 0])
print(list(ll)) #[0, 4, 16, 36, 64]
l2 = zip([1,2,3,4,5,6], ('a', "b", "c", "d", "e"))
print(list(l2)) #[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')]
l3 = zip((1,2,3), ('a', "b", "c", "d", "e"))
print(list(l3)) #[(1, 'a'), (2, 'b'), (3, 'c')]
l4 = zip((1, 2, 3), {'a', 'b'})
print(list(l4)) #这里的输出不固定,因为集合是无序的
ff = filter(lambda x: x<3, [x for x in range(5)])
print(list(ff)) #[0, 1, 2]
from functools import reduce
re = reduce(lambda x, y: x-y, [x for x in range(10)])
print(re) #对列表中的值,刚开始取2个,然后第三个和前两个数操作的值,进行操作,结果再和第四个数据进行操作,一次进行,-45
re2 = reduce(lambda x,y: x+y, [1, 3, 5, 7, 9])
print(re2) #25
re3 = reduce(lambda x,y:x+y, [1])
print(re3) #如果迭代器输入的数据数列长度未1的话,直接返回
re4 = reduce(lambda x,y:x+y, [1, 4, 6, 7, 7, 7], 100)
print(re4) #132, 很奇怪,这里可以给个初始值,但是初始值不能通过initial=100的方式进行赋值。
3.其他内置函数: