Python内建函数

dir():该方法将最大限度地收集参数信息

range(start,stop,[,step]):计数,最后一个为跳跃间距,默认为1

map(function,sequence[,sequence,……])把

序列中的元素,用指定的函数做处理,返回一个迭代器     

map(lambda x: x ** 2, [1, 2, 3, 4, 5]) #1,3,4

map(lambda x,y: x +y, [1, 2, 3],[4,5,6])#5,7,9

filter(function,sequence[,sequence,……])用指定的函数过滤序列中的元素,返回为True的过滤,返回一个迭代器

filter(lambda x:x%2,[1,2,3,4])#1.3

reduce(function,sequence[,sequence,……])对参数序列中元素进行累积,在Python3中被放置在functools模块里

reduce(lambda x,y:x+y,[1,2,3,4])#10

猜你喜欢

转载自blog.csdn.net/mr_quiet/article/details/81066935