日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名)

發布時間:2025/3/20 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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.在數組中構造包含原始數據字節的Python字節。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.構造Python字節,顯示數據存儲器原始內容的副本。 bytes對象可以按“ C”或“ Fortran”或“任何”順序生成(默認為“ C”順序)。 除非設置數組中的F_CONTIGUOUS標志,否則“任何”順序都表示C順序,在這種情況下,它表示“ Fortran”順序。This function is a compatibility alias for tobytes. Despite its name it returns bytes not strings.此功能是tobyte的兼容性別名。 盡管它的名字,它返回字節而不是字符串。Parameters----------order : {'C', 'F', None}, optionalOrder of the data for multidimensional arrays:C, Fortran, or the same as for the original array.多維數組的數據順序:C,Fortran或與原始數組相同。Returns-------s : bytesPython bytes exhibiting a copy of `a`'s raw data.展示a原始數據副本的Python字節。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')(每個數是int16位的,所以四個16進制數表示一個數字(兩個16進制數=一個字節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):

總結

以上是生活随笔為你收集整理的numpy ndarray.tostring()(在数组中构造包含原始数据字节的Python字节)(tobytes()函数的兼容性别名)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。