Python itertools 模塊中的 product 函數

product 用於求多個可迭代對象的笛卡爾積 (Cartesian Product)

可用於同時歷遍循環多個對象

from itertools import product

l1 = ['a', 'b','c']
l2 = [1, 2, 3]
for i, j in product(l1, l2):
    print(i, j)

輸出:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章