[英]Python combination of n dimensional array elements
我有一個數組列表如下
list1 = [['01', '02', '03', '04', '05', '06'], ['01', '64', '2f'], ['00', '1f', '17']]
我需要這些元素的所有可能組合,例如
010100, 01011f, 010117, 010200, 01021f, etc.
您可以使用itertools.product
並獲得您想要的:
import itertools
list1 = [['01', '02', '03', '04', '05', '06'], ['01', '64', '2f'], ['00', '1f', '17']]
for prd in itertools.product(*list1):
print(''.join(prd))
輸出:
010100
01011f
010117
016400
01641f
016417
012f00
...
062f00
062f1f
062f17
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.