2024-03-29 06:54:13 发布
网友
带形状的numpy(5,1) 包含以下元素:
[[1] [2] [3] [4] [5]]
如何遍历并打印每个元素? 具体如下:
1 2 3 4 5
尝试
for row in range(N): for col in range(D): print(input_array[row][col])
错误
Error: IndexError: index 1 is out of bounds for axis 0 with size 1
您的N, D值一定是错误的。要么这样
N, D
N, D = input_array.shape
继续你的代码,或者直接
for row in input_array: for token in row: print(token)
根据错误,N值是错误的。它应该是[0]。你知道吗
N
[0]
使用numpy.ndarray.shape函数计算时应返回正确的行和列值。你知道吗
您的
N, D
值一定是错误的。要么这样继续你的代码,或者直接
根据错误,
N
值是错误的。它应该是[0]
。你知道吗使用numpy.ndarray.shape函数计算时应返回正确的行和列值。你知道吗
相关问题 更多 >
编程相关推荐