python a all_Python:“在遍历numpy.ndarray时使用a.any()或a.all()”

是的,我认为你的numpy.array有一个额外的括号,或者它包含了另一个数组。

尝试手动将数组设置为myarray=np.array([[ 0.47174344, 0.45314669, 0.46395022, 0.47440382, 0.50709627,0.53350065, 0.5233444 , 0.49974663, 0.48721607, 0.46239652, 0.4693633 , 0.47263569, 0.47591957, 0.436558 , 0.43335574,0.44053621, 0.42814804, 0.43201894, 0.43973886, 0.44125302, 0.41176999],[ 0.46509004, 0.46221505, 0.48824086, 0.50088744, 0.53040384,0.53592231, 0.49710228, 0.49821022, 0.47720381, 0.49096272,0.50438366, 0.47173162, 0.48813669, 0.45032002, 0.44776794,0.43910269, 0.43326132, 0.42064458, 0.43472954, 0.45577299,0.43604956]])

代码也起作用了

但背景:myarray=np.array([[[ 0.47174344, 0.45314669, 0.46395022, 0.47440382, 0.50709627,0.53350065, 0.5233444 , 0.49974663, 0.48721607, 0.46239652, 0.4693633 , 0.47263569, 0.47591957, 0.436558 , 0.43335574,0.44053621, 0.42814804, 0.43201894, 0.43973886, 0.44125302, 0.41176999],[ 0.46509004, 0.46221505, 0.48824086, 0.50088744, 0.53040384,0.53592231, 0.49710228, 0.49821022, 0.47720381, 0.49096272,0.50438366, 0.47173162, 0.48813669, 0.45032002, 0.44776794,0.43910269, 0.43326132, 0.42064458, 0.43472954, 0.45577299,0.43604956]]])

产生了类似的错误

你可能感兴趣的:(python,a,all)