NumPy的操作介绍
import numpy as np print "Generate 1*10 matrix" a=np.arange(1,11)**2 b=np.arange(1,11)**3 c=a+b print c print c.shape print "create a 2*10 matrix" m=np.array([np.arange(10),np.arange(10)]) #create a 2*10 matrix print m print m.shape print "generate zero matrix" z1=np.zeros(10,dtype=np.int8) #create zero matrix z2=np.zeros([3,4]) print z1 print z2 print "generate empty matrix" e=np.empty([2,2]) #create empty matrix print e print "create identity matrix with data type equals int8" eye1=np.eye(5,dtype=np.int8) #create identity matrix print eye1 print eye1[0,0] #get element by index print eye1[3,4] print "calculation between two matrix" arr1=np.array([[1,2,3],[4,5,6]]) #calculation between two matrix arr2=arr1*arr1 print arr1 print arr2 print arr2-arr1 print arr2/arr1 print arr2%arr1 print "calculation between a matrix and a number" print 1/arr1 print arr1*0.3 print arr1+0.08 print arr1-0.33