数据类型无法理解 [英] data type not understood
本文介绍了数据类型无法理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用矩阵来计算东西.代码是这个
I'm trying to use a matrix to compute stuff. The code is this
import numpy as np
# some code
mmatrix = np.zeros(nrows, ncols)
print mmatrix[0, 0]
但是我得到无法理解的数据类型",并且如果我从终端执行此操作也可以.
but I get 'data type not understood', and it works if I do it from terminal.
推荐答案
尝试:
mmatrix = np.zeros((nrows, ncols))
由于shape参数必须是int或int序列
Since the shape parameter has to be an int or sequence of ints
http://docs.scipy.org/doc/numpy/reference/generation/numpy.zeros.html
否则,您会将ncols
作为dtype传递给np.zeros
.
Otherwise you are passing ncols
to np.zeros
as the dtype.
这篇关于数据类型无法理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文