Generating Combinations in python

后端 未结 3 1697
忘了有多久
忘了有多久 2020-12-29 07:54

I am not sure how to go about this in Python, if its even possible. What I need to do is create an array (or a matrix, or vector?) from 3 separate arrays. Each array as 4

3条回答
  •  孤城傲影
    2020-12-29 08:32

    What you want is called a Cartesian product:

    import itertools
    
    iterables = [ [1,2,3,4], [88,99], ['a','b'] ]
    
    for t in itertools.product(*iterables):
        print t
    

提交回复
热议问题