需求:已知兩個列表,如今要一個列表中的元素,分別所有插入另外一個列表中,新列表是[[0, 9, 1], [0, 9, 2], [0, 9, 3], [0, 9, 4], [0, 9, 5], [0, 9, 6], [0, 9, 7]]
代碼實現:
search = [0,9] list_num = [1,2,3,4,5,6,7] r = map(lambda x:search+[x], list_num) print(list(r))
獲得的就是spa
[[0, 9, 1], [0, 9, 2], [0, 9, 3], [0, 9, 4], [0, 9, 5], [0, 9, 6], [0, 9, 7]]code