当前位置: 移动技术网 > IT编程>脚本编程>Python > 求助!被python折腾到头秃啊!!

求助!被python折腾到头秃啊!!

2020年07月16日  | 移动技术网IT编程  | 我要评论

在学习python矩阵相关内容的时候,根据例子编程如下:

from numpy import *
a_1 = [1,2,3]
a_2 = [4,5,6]
a_3 = [7,8,9]
a10 = mat([a_1,a_2,a_3])
x = a10.sum(axis=0)
print('sum column is',x)
y = a10.sum(axis=1)
print('sum row is',y)
z = sum(a10[0,:])
print('sum first row is',z)
#最大值最小值
a11 = a10
a11_1 = a11.max()
a11_2 = max(a11[:,1])
a11_3 = np.max(a11 ,0)

最后一行是想要得到所有列的最大值

报错说:NameError: name 'np' is not defined

去掉“np”也是错的:ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

所以应该怎么办???

本文地址:https://blog.csdn.net/lz9797/article/details/107349935

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网