本文簡要介紹 python 語言中 numpy.ndarray.copy
的用法。
用法:
ndarray.copy(order='C')
返回數組的副本。
- order: {‘C’、‘F’、‘A’、‘K’},可選
控製副本的內存布局。 “C”表示C-order,“F”表示F-order,“A”表示“F”,如果a是 Fortran 連續的,否則為“C”。 ‘K’表示匹配布局a盡可能接近。 (請注意,此函數和numpy.copy非常相似,但它們的 order= 參數具有不同的默認值,並且此函數始終傳遞子類。)
參數:
注意:
此函數是創建數組副本的首選方法。函數
numpy.copy
類似,但默認使用順序‘K’,默認不傳遞子類。例子:
>>> x = np.array([[1,2,3],[4,5,6]], order='F')
>>> y = x.copy()
>>> x.fill(0)
>>> x array([[0, 0, 0], [0, 0, 0]])
>>> y array([[1, 2, 3], [4, 5, 6]])
>>> y.flags['C_CONTIGUOUS'] True
相關用法
- Python numpy ndarray.ctypes用法及代碼示例
- Python numpy ndarray.astype用法及代碼示例
- Python numpy ndarray.flat用法及代碼示例
- Python numpy ndarray.setflags用法及代碼示例
- Python numpy ndarray.setfield用法及代碼示例
- Python numpy ndarray.sort用法及代碼示例
- Python numpy ndarray.real用法及代碼示例
- Python numpy ndarray.strides用法及代碼示例
- Python numpy ndarray.itemset用法及代碼示例
- Python numpy ndarray.__class_getitem__用法及代碼示例
- Python numpy ndarray.partition用法及代碼示例
- Python numpy ndarray.transpose用法及代碼示例
- Python numpy ndarray.flatten用法及代碼示例
- Python numpy ndarray.resize用法及代碼示例
- Python numpy ndarray.dtype用法及代碼示例
- Python numpy ndarray.imag用法及代碼示例
- Python numpy ndarray.dot用法及代碼示例
- Python numpy ndarray.size用法及代碼示例
- Python numpy ndarray.fill用法及代碼示例
- Python numpy ndarray.item用法及代碼示例
- Python numpy ndarray.nbytes用法及代碼示例
- Python numpy ndarray.tobytes用法及代碼示例
- Python numpy ndarray.view用法及代碼示例
- Python numpy ndarray.shape用法及代碼示例
- Python numpy ndarray.base用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.ndarray.copy。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。