9951 explained code solutions for 126 technologies


python-numpyConvert Numpy bytes to array


import numpy as np

bts = b'\x01\x02\x03'

a = np.array(np.frombuffer(bts, dtype=np.uint8));ctrl + c
import numpy as np

load Numpy module for Python

b'\x01\x02\x03'

sample byte string

.frombuffer(

converts given bytes to array with the specified type

dtype=np.uint8

specify one of Numpy type to use to convert from bytes

np.array

create Numpy array from given list