回到目錄 ☢️

import numpy as np
a=np.arange(6)
print(a)
print(a.argmax())
print(a[1:])
print(a[4::-1])
print(a[::2])
print(a[a%3==0])
a[a%3==0]=0
print(a)
print(np.unique(a))
▶︎
all
running...
[0 1 2 3 4 5]
5
[1 2 3 4 5]
[4 3 2 1 0]
[0 2 4]
[0 3]
[0 1 2 0 4 5]
[0 1 2 4 5]
import numpy as np
a=np.arange(6).reshape(3,-1)
a1=np.expand_dims(a,axis=0)
a2=np.squeeze(a1,axis=0)
print('a1='+ str(a1))
print('a2='+ str(a2))
▶︎
all
running...