>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> y = [[1,2,3], [4,5,6], [7,8,9]]
>>> map(lambda x: [i for i in range(len(y)) if y[i].count(x) > 0], x)
[[0], [0], [0], [1], [1], [1], [2], [2], [2]]
>>>
>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> y = [[1,2,3], [4,5,6], [7,8,9], [1,2,3]]
>>> map(lambda x: [i for i in range(len(y)) if y[i].count(x) > 0], x)
[[0, 3], [0, 3], [0, 3], [1], [1], [1], [2], [2], [2]]
>>>
>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> y = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 9, 7]]
>>> map(lambda x: [i for i in range(len(y)) if y[i].count(x) > 0], x)
[[0, 3], [0], [0], [1], [1], [1], [2, 3], [2], [2, 3]]
>>>
>>> x = [ 4, 5, 6, 7, 8, 9, 1, 2, 3]
>>> y = [[1, 2, 3], [7, 8, 9], [1, 9, 7], [4, 5, 6]]
>>> map(lambda x: [i for i in range(len(y)) if y[i].count(x) > 0], x)
[[3], [3], [3], [1, 2], [1], [1, 2], [0, 2], [0], [0]]
>>>
>>> x = [ 4, 5, 6, 7, 8, 9, 1, 2, 3]
>>> y = [[1, 2, 3], [7, 8, 9], [1, 9, 7], [4, 5, 6]]
>>> d = {}
>>> d.update(map(lambda x: (x, [i for i in range(len(y)) if y[i].count(x) > 0]), x))
>>> d
{1: [0, 2], 2: [0], 3: [0], 4: [3], 5: [3], 6: [3], 7: [1, 2], 8: [1], 9: [1, 2]}
>>>
我认为它有效!