import itertools
def x(a,b):
x = [[i] for i in itertools.product(a, repeat=b)]
return [x]
print (x({0,1},3))
输出是
[[[(0, 0, 0)], [(0, 0, 1)], [(0, 1, 0)], [(0, 1, 1)], [(1, 0, 0)], [(1, 0, 1)], [(1, 1, 0)], [(1, 1, 1)]]]
我想要的是它看起来像这样,所有的 () 都被删除了,开始和结束的 [] 被删除了
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]