
Python错误集合
windwm
这个作者很懒,什么都没留下…
展开
-
Python错误问题
IndexError: invalid index to scalar variable.生成了一个长度为10的一维数组,然后使用reshape转换成2x5的矩阵,但是在取矩阵值的时候出现索引错误import numpy as npa = np.arange(0,10)a.reshape(2,5)a[1][1]原因:数组a经过reshape后,a中的内容没有变,需要重新赋值import nu...原创 2018-03-15 20:52:28 · 35490 阅读 · 0 评论 -
Python错误问题2
IndexError: list assignment index out of range1.错误:生成一个空的list列表a = [],给a赋值的时候a[0] = 1时出现上述的错误>>> a = []>>> a[0] = 1Traceback (most recent call last): File "<input>", li...原创 2018-04-07 17:18:18 · 716 阅读 · 0 评论 -
Python错误问题3
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()使用numpy模块的array生成两个数组,在比较数组是否相等时,出现如上错误,程序如下:import numpy as npa = np.array([1,2,3])b = n...原创 2018-06-20 22:16:16 · 513 阅读 · 0 评论