numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名)
生活随笔
收集整理的這篇文章主要介紹了
numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
from numpy\core\multiarray
def tostring(self, order='C'): # real signature unknown; restored from __doc__"""a.tostring(order='C')Construct Python bytes containing the raw data bytes in the array.在數(shù)組中構(gòu)造包含原始數(shù)據(jù)字節(jié)的Python字節(jié)。Constructs Python bytes showing a copy of the raw contents ofdata memory. The bytes object can be produced in either 'C' or 'Fortran',or 'Any' order (the default is 'C'-order). 'Any' order means C-orderunless the F_CONTIGUOUS flag in the array is set, in which case itmeans 'Fortran' order.構(gòu)造Python字節(jié),顯示數(shù)據(jù)存儲器原始內(nèi)容的副本。 bytes對象可以按“ C”或“ Fortran”或“任何”順序生成(默認(rèn)為“ C”順序)。 除非設(shè)置數(shù)組中的F_CONTIGUOUS標(biāo)志,否則“任何”順序都表示C順序,在這種情況下,它表示“ Fortran”順序。This function is a compatibility alias for tobytes. Despite its name it returns bytes not strings.此功能是tobyte的兼容性別名。 盡管它的名字,它返回字節(jié)而不是字符串。Parameters----------order : {'C', 'F', None}, optionalOrder of the data for multidimensional arrays:C, Fortran, or the same as for the original array.多維數(shù)組的數(shù)據(jù)順序:C,Fortran或與原始數(shù)組相同。Returns-------s : bytesPython bytes exhibiting a copy of `a`'s raw data.展示a原始數(shù)據(jù)副本的Python字節(jié)。Examples-------->>> x = np.array([[0, 1], [2, 3]])>>> x.tobytes()b'\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00'>>> x.tobytes('C') == x.tobytes()True>>> x.tobytes('F')(每個數(shù)是int16位的,所以四個16進(jìn)制數(shù)表示一個數(shù)字(兩個16進(jìn)制數(shù)=一個字節(jié)8位),大端在前) (下面的貌似是小端在前)b'\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00'"""pass示例(https://gitee.com/dontla/obstacle_detection/blob/53bd75fb637ceb5c53480b9d8c77db5c36f4ce8d/191228_obstacle_detection_%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE.py):
總結(jié)
以上是生活随笔為你收集整理的numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python cv2.imencode(
- 下一篇: Intel Realsense D435