位元組陣列bytearray()

2021-09-24 15:35:44 字數 1110 閱讀 5303

序列:

常見的序列有:list, tuple, str, bytes, bytearray

位元組串 bytes,位元組陣列bytearray是二進位制資料組成的序列,其中每個元素8bit二進位制組成

位元組陣列bytearray

可變的位元組序列,相當於bytes的可變版本

建立bytearray物件的方法規則

import numpy as np

import jpeg4py as jpeg

import cv2

im_path='/home/jerry/shared/data/car_detect/test_image/timg.jpeg'

with open(im_path, 'rb') as file:

encoded_image = file.read()

print('wp1',len(encoded_image),encoded_image)#3do\x94\n\xc9\x18\xdf\x8c&\r\x,類似於二進位制的表達方式

encoded_image = np.array(bytearray(encoded_image), dtype=np.uint8) # 把資料轉換為位元組陣列

print('p2',len(encoded_image),encoded_image)#877724 [255 216 255 ... 107 255 217]這裡是乙個一維的陣列,共有877724 個元素

def imread(im_path):

try:

img = jpeg.jpeg(im_path).decode()[..., ::-1] # rgb -> bgr

except exception as ex:

img = cv2.imread(im_path, cv2.imread_color)

return img

image = imread(im_path)#這種方式的資料量比較大s

print(image.shape)#(2304, 4096, 3)

#總結,可以明顯看出,第一種的序列方式資料量小

unity AssetBundle位元組陣列加密

1.加密 對assetbundle的位元組陣列每位進行與key的異或處理 相同為0,不同為1 using system using system.collections.generic using system.io using system.linq using system.text names...

位元組陣列 Byte

位元組 byte 發音 bait 位元組是通過網路傳輸資訊 或在硬碟或記憶體中儲存資訊 的單位。在ascii碼中,乙個英文本母 不分大小寫 佔乙個位元組的空間,乙個中文漢字佔兩個位元組的空間。符號 英文標點佔乙個位元組,中文標點佔兩個位元組。舉例 英文句號 佔1個位元組的大小,中文句號 佔2個位元組...

位元組陣列流

位元組陣列流 bytearrayinputstream 包含乙個內部緩衝區,該緩衝區包含從流中讀取的位元組。內部計數器跟蹤read方法要提供的下乙個位元組。關閉bytearrayinputstream無效。此類中的方法再關閉流後依然可以被呼叫,而不會產生任何ioexception.bytearray...