Merging the results of itertools.product?

后端 未结 3 676
长情又很酷
长情又很酷 2021-01-25 05:49

I am trying to create a list of numbers from 0-9999 using itertools.product. I am able to create a list from 0000-9999 by doing the follow

3条回答
  •  走了就别回头了
    2021-01-25 06:15

    numbers = ['0','1','2','3','4','5','6','7','8','9']
    list(''.join(subl) for subl in itertools.chain.from_iterable(itertools.product(numbers, repeat=i) for i in range(1,5)))
    

提交回复
热议问题