#language zh = NumPy = * 主页:http://numeric.scipy.org * 相关模块:[[Numeric]], [[Numarray]] 建议导入方法 {{{#!python import numpy }}} 然后就可以在 `numpy` 名字空间内使用它自带的各个子模块 == 子模块总揽 == NumPy包含的子模块 {{{#!CSV Sub-Package; Purpose; Comments core; basic objects; all names exported to numpy lib; additional utilities; all names exported to numpy linalg; basic linear algebra; old LinearAlgebra from Numeric dft; discrete Fourier transforms; old FFT from Numeric random; random number generators; old RandomArray from Numeric distutils; enhanced build and distribution; improvements for standard distutils testing; unit-testing; utility functions useful for testing f2py; automatic wrapping of Fortran code; a useful utility needed by SciPy }}} <> == 基本对象 == '''NumPy 提供了两个基本对象: N-维矩阵对象(ndarray)和通用函数对象(ufunc)。其他的对象都是建立在这两个对象之上的。''' '''注意:矩阵元素的索引从`0`开始,到`n-1`结束,这是为了与Python中的其他对象兼容而做''' 定义`2x3`整型矩阵,每个元素占有4个字节(32-bit平台)。通过方括号进行元素索引。 {{{#!python >>> a = numpy.array([[1,2,3],[4,5,6]]) >>> a array([[1, 2, 3], [4, 5, 6]]) >>> a.shape (2, 3) >>> a.dtype dtype('>> a[1,1] 5 }}}