Python-访问NumPy数组项

Python-访问NumPy数组项,python,numpy,Python,Numpy,我是很长一段时间以来第一次使用Python,有点不知所措。我有一个numPy数组,当我打印它时它看起来像这样 [[148 362] [153 403] [163 443] [172 483] [186 521] [210 553] [239 581] [273 604] [314 611] [353 602]] 我试图从数组中获取5项,并将其保存为2个变量,x和y 我已经尝试使用 print("It

我是很长一段时间以来第一次使用Python,有点不知所措。我有一个
numPy
数组,当我打印它时它看起来像这样

   [[148 362]
     [153 403]
     [163 443]
     [172 483]
     [186 521]
     [210 553]
     [239 581]
     [273 604]
     [314 611]
     [353 602]]
我试图从数组中获取5项,并将其保存为2个变量,x和y

我已经尝试使用

print("Item 5" + numpy_array[5])
但这给了我一个错误

typeError: ufunc 'add' did not contain a loop with signature matching types dtype('S21') dtype('S21') dtype('S21')

假设数组存储在名为
numpy\u array
的变量中,只需执行以下操作。由于子阵列包含2个元素,因此它将把值解压为x和y

x, y = numpy_array[5]
print (x, y)
# (210, 553)

以下是其他例子:

print("Item 5: " + str(numpy_array[5]) ) #=> Item 5: [210 553]

print("Item 5: ", numpy_array[5][0], numpy_array[5][1] ) #=> Item 5:  210 553

print("Item 5: ", numpy_array[5][0], "-" , numpy_array[5][1] ) #=> Item 5:  210 553

print (f"Item 5: {numpy_array[5][0]}, {numpy_array[5][1]}" ) #=> Item 5: 210, 553

谢谢你,有很多不同的选择,