【发布时间】:2019-04-26 23:54:32
【问题描述】:
考虑以下 sn-p:
a = np.ones((2,2,2,2,2))
for example in a:
for row in example:
for col in row:
for box in col:
print (box.shape)
有这么多嵌套的fors 会导致一些非常丑陋的代码。
如何仅通过一次显式迭代获得相同的效果?
【问题讨论】:
标签: python arrays python-3.x numpy iteration