[英]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. 但是我得到“无法理解的数据类型”,而且如果我从终端执行此操作也可以。
Try: 尝试:
mmatrix = np.zeros((nrows, ncols))
Since the shape parameter has to be an int or sequence of ints 由于shape参数必须是int或int序列
http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html http://docs.scipy.org/doc/numpy/reference/generation/numpy.zeros.html
Otherwise you are passing ncols
to np.zeros
as the dtype. 否则,您np.zeros
ncols
作为np.zeros
传递给np.zeros
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.