【问题标题】:data type not understood数据类型不理解
【发布时间】:2011-07-23 17:21:10
【问题描述】:

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

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

但我得到“不理解的数据类型”,如果我从终端执行它,它就可以工作。

【问题讨论】:

    标签: python matrix numpy


    【解决方案1】:

    试试:

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

    因为形状参数必须是整数或整数序列

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

    否则,您会将 ncols 作为 dtype 传递给 np.zeros

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-16
      • 2018-05-24
      • 2021-06-11
      • 2020-03-25
      • 1970-01-01
      • 2021-07-17
      • 1970-01-01
      • 2018-12-01
      相关资源
      最近更新 更多