数据类型不懂

data type not understood

提问人:zzzbbx 提问时间:3/27/2011 更新时间:3/27/2011 访问量:186318

问:

我正在尝试使用矩阵来计算东西。代码是这样的

import numpy as np
# some code
mmatrix = np.zeros(nrows, ncols)
print mmatrix[0, 0]

但是我得到“数据类型不理解”,如果我从终端执行此操作,它会起作用。

矩阵 麻木

评论


答:

163赞 JoshAdel 3/27/2011 #1

尝试:

mmatrix = np.zeros((nrows, ncols))

由于 shape 参数必须是 int 或 int 序列

http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html

否则,您将作为 dtype 传递。ncolsnp.zeros