開始使用免費開始

dtype 參數

控制 NumPy 陣列的資料型別,其中一種方式是建立陣列時用 dtype 關鍵字參數指定。先看看用 np.zeros() 建立陣列時,NumPy 預設採用的資料型別是什麼。可以把它改成別的嗎?

已載入 numpy 並命名為 np

本練習屬於課程

NumPy 入門

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Create an array of zeros with three rows and two columns
zero_array = ____

# Print the data type of zero_array
print(____)
編輯並執行程式碼