首页 > 代码库 > Scipy - science python
Scipy - science python
http://blog.csdn.net/pipisorry/article/details/43277755
Scipy中引入包错误:
...
scipy.misc.imsave(filename, numpy.kron(doc, zoom))...
AttributeError: ‘module‘ object has no attribute ‘misc‘
发生错误的原因:
Most possibly because scipy is a library (package) that contains modules and to import a specific module from the scipy library, you need to specify it and import the module itself. As it‘s a separate module (sub-package), once you import it, it‘s attributes are available to you by using the regular scipy.module.attribute.
The modules inside scipy aren‘t accessible as attributes of the base scipy package.
对引入格式的说明
In Python the distinction between what is the public API of a library and whatare private implementation details is not always clear. Unlike in otherlanguages like Java, it is possible in Python to access “private” function orobjects. Occasionally this may be convenient, but be aware that if you do soyour code may break without warning in future releases. Some widely understoodrules for what is and isn’t public in Python are:
- Methods / functions / classes and module attributes whose names beginwith a leading underscore are private.
- If a class name begins with a leading underscore none of its members arepublic, whether or not they begin with a leading underscore.
- If a module name in a package begins with a leading underscore none ofits members are public, whether or not they begin with a leadingunderscore.
- If a module or package defines __all__ that authoritatively defines thepublic interface.
- If a module or package doesn’t define __all__ then all names that don’tstart with a leading underscore are public.
Note:Reading the above guidelines one could draw the conclusion that everyprivate module or object starts with an underscore. This is not thecase; the presence of underscores do mark something as private, butthe absence of underscores do not mark something as public.
【API - importing from Scipy】
解决:
You need to do import scipy.misc
orfrom scipy import misc
.
from:http://blog.csdn.net/pipisorry/article/details/43277755
ref:
Scipy - science python