輸入和輸出#

NumPy 二進位檔案 (npy, npz)#

load(file[, mmap_mode, allow_pickle, ...])

.npy.npz 或 pickle 檔案載入陣列或 pickled 物件。

save(file, arr[, allow_pickle, fix_imports])

以 NumPy .npy 格式將陣列儲存到二進位檔案。

savez(file, *args[, allow_pickle])

以未壓縮的 .npz 格式將多個陣列儲存到單一檔案。

savez_compressed(file, *args[, allow_pickle])

以壓縮的 .npz 格式將多個陣列儲存到單一檔案。

lib.npyio.NpzFile(fid)

類似字典的物件,在建構時提供壓縮檔中檔案的延遲載入。

這些二進位檔案類型的格式記錄在 numpy.lib.format

文字檔案#

loadtxt(fname[, dtype, comments, delimiter, ...])

從文字檔案載入資料。

savetxt(fname, X[, fmt, delimiter, newline, ...])

將陣列儲存到文字檔案。

genfromtxt(fname[, dtype, comments, ...])

從文字檔案載入資料,並處理指定的遺失值。

fromregex(file, regexp, dtype[, encoding])

使用正則表達式解析從文字檔案建構陣列。

fromstring(string[, dtype, count, like])

從字串中的文字資料初始化的新 1-D 陣列。

ndarray.tofile(fid[, sep, format])

將陣列寫入檔案作為文字或二進位 (預設)。

ndarray.tolist()

將陣列作為 a.ndim 層級深的 Python 純量巢狀串列傳回。

原始二進位檔案#

fromfile(file[, dtype, count, sep, offset, like])

從文字或二進位檔案中的資料建構陣列。

ndarray.tofile(fid[, sep, format])

將陣列寫入檔案作為文字或二進位 (預設)。

字串格式化#

array2string(a[, max_line_width, precision, ...])

傳回陣列的字串表示形式。

array_repr(arr[, max_line_width, precision, ...])

傳回陣列的字串表示。

array_str(a[, max_line_width, precision, ...])

傳回陣列中資料的字串表示形式。

format_float_positional(x[, precision, ...])

以位置標記法將浮點純量格式化為十進位字串。

format_float_scientific(x[, precision, ...])

以科學記號標記法將浮點純量格式化為十進位字串。

記憶體映射檔案#

memmap(filename[, dtype, mode, offset, ...])

建立磁碟上二進位檔案中儲存之陣列的記憶體映射。

lib.format.open_memmap(filename[, mode, ...])

將 .npy 檔案開啟為記憶體映射陣列。

文字格式化選項#

set_printoptions([precision, threshold, ...])

設定列印選項。

get_printoptions()

傳回目前的列印選項。

printoptions(*args, **kwargs)

用於設定列印選項的上下文管理器。

Base-n 表示法#

binary_repr(num[, width])

傳回輸入數字的二進位表示形式,作為字串。

base_repr(number[, base, padding])

傳回給定基底系統中數字的字串表示形式。

資料來源#

lib.npyio.DataSource([destpath])

通用資料來源檔案 (file, http, ftp, ...)。

二進位格式描述#

lib.format

二進位序列化