【发布时间】:2012-01-31 13:14:10
【问题描述】:
有一件事我不明白。
为什么会这样
import scipy # happens with several other modules, too. I took scipy as an example now...
matrix = scipy.sparse.coo_matrix(some_params)
产生这个错误:
AttributeError: 'module' object has no attribute 'sparse'
【问题讨论】:
-
这有什么麻烦?如果模块中不存在
sparse,您期望会发生什么? -
我没有意识到,sparse 是 scipy 的 子模块,子模块是 not 自动导入的- 正如@David Zaslavsky 在下面指出的那样。
-
投反对票的人应该解释他们投反对票的原因,我看不出这个问题有什么问题。其实我觉得这是一个很好的问题
-
感谢@julio.alegria,很高兴听到其他人的消息。 :-)
标签: python import attributeerror