📜  python 从两个列表中获取唯一对 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.302000             🧑  作者: Mango

代码示例1
# note: this works for two list only
from itertools import product

l1 = [1,2,3]
l2 = [4,5,6] # works if the second list has a different lenght too

product(l1, l2)
>>> 

list(product(l1, l2))
>>> [(1, 4), (1, 5), (1, 6), 
     (2, 4), (2, 5), (2, 6), 
     (3, 4), (3, 5), (3, 6)]