如numpy,我看了github上numpy的包结构,发现numpy就是一个包,但其__init__.py文件并没有ones()之类的函数定义,也没有对其的import引用,那么为什么我import numpy之后,可以写numpy.ones()来调用这个函数呢。
如numpy,我看了github上numpy的包结构,发现numpy就是一个包,但其__init__.py文件并没有ones()之类的函数定义,也没有对其的import引用,那么为什么我import numpy之后,可以写numpy.ones()来调用这个函数呢。
用help哦,就可以看到位置在 numpy.core.numeric
help(numpy.ones)
Help on function ones in module numpy.core.numeric:
ones(shape, dtype=None, order='C')
Return a new array of given shape and type, filled with ones.
Parameters
----------
shape : int or sequence of ints
Shape of the new array, e.g., ``(2, 3)`` or ``2``.
dtype : data-type, optional
The desired data-type for the array, e.g., `numpy.int8`. Default is
`numpy.float64`.
order : {'C', 'F'}, optional
Whether to store multidimensional data in C- or Fortran-contiguous
(row- or column-wise) order in memory.
Returns
-------
out : ndarray
Array of ones with the given shape, dtype, and order.
See Also
--------
4 回答4.5k 阅读✓ 已解决
1 回答3.4k 阅读✓ 已解决
4 回答3.8k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
1 回答4.5k 阅读✓ 已解决
1 回答3.9k 阅读✓ 已解决
2 回答432 阅读✓ 已解决
numpy/__init__.py
里有一句:然后
core/__init__.py
里有一句: