I have an hexa string that I want to convert to a numpy array of int.
I don't want to use for
loops because looping through numpy arrays is not advised.
So I do the following :
vector = np.fromstring( s.decode('hex'), dtype=np.uint8 )
If for example s = 'a312'
, s.decode('hex')
returns '\xa3\x12'
which is correct.
But if s = 'a320'
, s.decode('hex')
returns '\xa3 '
which seems a little bit weird as first sight because I expect '\xa3\x20'
.
Can you help me ?