Python lambda 多变量
>> x = list(map(lambda x, y: (x>3, y>0), (1,2,3,4,5), (0,1,2,3,4)))
>>> x
[(False, False), (False, True), (False, True), (True, True), (True, True)]
>>> x = list(map(lambda x, y: (x*y), (1,2,3,4,5), (0,1,2,3,4)))
>>> x
[0, 2, 6, 12, 20]
>>>
>>> x = list(map(lambda x, y: (x*y), (1,2,3,4,5), (0,1,2,3)))
>>> x
[0, 2, 6, 12]
>>>
两个列表不能相乘
>>> l1 = [1, 2, 3]
>>> l2 = [2, 3, 4]
>>> l = l1 * l2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't multiply sequence by non-int of type 'list'
>>> l = l1 * 3
>>> l
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> l = l1 + l2
>>> l
[1, 2, 3, 2, 3, 4]
>>>