2012-02-04 40 views

回答

10

itertools.starmap此提出:

import itertools 

def func1(a, b, c): 
    return a+b+c 

print list(itertools.starmap(func1, [[1,2,3],[4,5,6],[7,8,9]])) 

输出:

[6, 15, 24] 
5

你不能。使用包装。

def func1(a, b, c): 
    return a+b+c 

map((lambda x: func1(*x)), [[1,2,3],[4,5,6],[7,8,9]]) 
3

你可以简单地换另外一个新功能只需要一个参数作为一个元组/列表里面的多参数函数,然后将其传递到内部函数。

map(lambda x: func(*x), [[1,2,3],[4,5,6],[7,8,9]])