【发布时间】:2021-10-12 21:17:03
【问题描述】:
我的代码有错误,我做了测试代码。
我的测试代码的一点描述:我导入了numpy模块。
我为起始坐标做了变量,然后做了array 7×4。
之后,我进入循环for 并遍历数组,在该数组中我从变量中执行步骤x by 10 和y by 5 以获取起始坐标。
然后我在数组中添加x 和y 中的数组和数组中的数组.Printed array:3** 当我开始编写代码时,我就有了:
ValueError: cannot copy sequence with size 2 to array axis with dimension 4
如何解决这个错误?
这是代码:
import numpy as np
#FOR TEST
pose = (640, 154)
all_poses = np.zeros((1, 7, 4))
for i in range(0, 6):
for j in range(0, 4):
y = pose[1] - i * 5
x = pose[0] - j * 10
cortege = (x, y)
all_poses[i, j] = cortege
print(all_poses)
【问题讨论】:
标签: python arrays numpy for-loop valueerror