numpy.ndarray.tobytes()函數構造包含數組中原始數據字節的Python字節。
用法: numpy.ndarray.tobytes(order=’C’)
參數:
order:[{'C','F',無},可選]多維數組的數據順序:C,Fortran或與原始數組相同。
Return :Python字節顯示了arr的原始數據的副本。
代碼1:
# Python program explaining
# numpy.ndarray.tobytes() function
# importing numpy as geek
import numpy as geek
arr = geek.array([[0, 1], [2, 3]], dtype ='<u2')
gfg = arr.tobytes()
print (gfg)
輸出:
b'\x00\x00\x01\x00\x02\x00\x03\x00'
代碼2:
# Python program explaining
# numpy.ndarray.tobytes() function
# importing numpy as geek
import numpy as geek
arr = geek.array([[0, 1], [2, 3]], dtype ='<u2')
gfg = arr.tobytes('F')
print (gfg)
輸出:
b'\x00\x00\x02\x00\x01\x00\x03\x00'
相關用法
- Python numpy.ix_()用法及代碼示例
- Python numpy.cov()用法及代碼示例
- Python numpy.ma.make_mask_none()用法及代碼示例
- Python numpy.ma.flatnotmasked_contiguous()用法及代碼示例
- Python numpy.ma.flatnotmasked_edges()用法及代碼示例
- Python numpy.ma.mask_cols()用法及代碼示例
- Python numpy.ma.notmasked_edges()用法及代碼示例
- Python numpy.ma.clump_unmasked()用法及代碼示例
- Python numpy.ma.clump_masked()用法及代碼示例
- Python numpy.mask_indices()用法及代碼示例
- Python numpy.vander()用法及代碼示例
- Python numpy.unravel_index()用法及代碼示例
- Python numpy.ravel_multi_index()用法及代碼示例
- Python numpy.ma.mask_or()用法及代碼示例
注:本文由純淨天空篩選整理自sanjoy_62大神的英文原創作品 Numpy ndarray.tobytes() function | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。