1 >>> z1=[1,2,3]
2 >>> z2=[4,5,6]
3 >>> result=zip(z1,z2)
zip()配合*号操作符,可以将已经zip过的列表对象解压,即将合并的序列拆成多个...例如:
a=[0,1,2,3,4,5,6,7]
map(lambda x:x+3, a)
a=[1,2,3]
b=[4,5,6]
map(lambda x,y:x+y, a,b)
[5,7,9...x3 ), x4 )
使用范例如下:
#str to int
def str2int(s):
return reduce(lambda x,y: x*10+y, map(int, s)...)
妙用集锦: http://devopstarter.info/pythonkai-fa-zhi-mapreduce/
#两个list,取(x - y) + (y - x)
x=[{'a': 1, '...b': 2}, {'c': 3}, {'d': 4}]
y=[{'a': 1}, {'c': 3}, {'e': 5}]
filter(lambda z: (x+y).count(z)<2, (x+