a = (1,2,3)
b = ('a','b')
x = itertools.product(a,b)
print(list(x))
就是知乎上看到的这段代码,让我疑问了好久了。
它返回的是一个迭代器,可以用 next() 逐个取值
>>> import itertools as it
>>> t = it.product((1,2,3),['a','b'])
>>> type(t)
<class 'itertools.product'>
>>> next(t)
(1, 'a')
>>> next(t)
(1, 'b')
成千上万?你是想说你传入的参数元素很多?