int8 |
8 位元有號整數 |
int16 |
16 位元有號整數 |
int32 |
32 位元有號整數 |
int64 |
64 位元有號整數 |
uint8 |
8 位元無號整數 |
uint16 |
16 位元無號整數 |
uint32 |
32 位元無號整數 |
uint64 |
64 位元無號整數 |
float16 |
16 位元浮點數 |
float32 |
32 位元浮點數 |
import numpy as np
x=np.array([1,2,3],dtype=np.int16)
print(x,type(x))
print(x[0],type(x[0]))


import numpy as np
def myfun(a:np.ndarray):
return sum(a)
lst = [1,2,3]
ary = np.array(lst)
print(“list: %r, Type: %r”%(lst,type(lst)) )
print(“Array: %r, Type: %r” %( ary ,type(ary)))
print(“Summation:”,myfun(ary) )
lst2D = [
[1,2,3],
[4,5,6]
]
ary2D = np.array(lst2D)
print(ary2D)
print( “Type of 2D array:”,type(ary2D) )
#一樣是numpy.ndarray,沒有顯示維度







![Python 表達式中的魔法:用海象運算子讓斷詞程式碼更乾淨 [w_clean for w in words if (w_clean:=w.lower().strip()) and w_clean not in STOPWORDS] Python 表達式中的魔法:用海象運算子讓斷詞程式碼更乾淨 [w_clean for w in words if (w_clean:=w.lower().strip()) and w_clean not in STOPWORDS]](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2026/02/20260210083748_0_a7d9bf.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言