擅长:python、mysql、java
<p>我不知道这有多有效,但你应该能做这样的事。。。在</p>
<pre><code>shape = (2, 4, 3)
axes = (2, 0, 1)
# Needed to get the original ordering back
axes_undo = tuple(reversed(axes))
# Reorder the shape in a configuration so that .product will give you
# the order you want.
reordered = tuple(reversed(map(lambda x: shape[x], list(axes))))
# When printing out the results from .product, put the results back
# into the original order.
for i in itertools.product(*(range(x) for x in reordered)):
print(tuple(map(lambda x: i[x], list(axes_undo))))
</code></pre>
<p>我尝试了4个维度,它似乎有效。;)</p>
<p>我只是交换一下尺寸然后再交换回来。在</p>