一、和标量进行运算
import numpy as np
a = np.arange(10)
print(a)
b = a +1
print(b)
image.png
二、两个二维数组进行运算(前提:大小一致)
import numpy as np
a = np.arange(10)
print("a是:",a)
c = np.arange(10,20)
print("c是:",c)
d = a * c
print("a与c相乘的结果是:",d)
e = d > a
print(e)
image.png
ede jieguo
三、一维与二维数组取值
import numpy as np
c = np.arange(10,20)
print("一维数组取值:",c[0])
f = np.arange(15).reshape((3,5))
print(f)
print("二维数组取值:",f[0,0])
image.png
四、切片
f = np.arange(15).reshape((3,5))
print(f)
print("二维数组切片:","\n",f[0:2,0:2])
image.png
网友评论