Home > Blockchain >  how to convert string with hexadecimal characters transformed into a list of hexadecimal integers
how to convert string with hexadecimal characters transformed into a list of hexadecimal integers

Time:09-19

I'm trying to create a list of hexadecimal integers from a string of hexadecimal digits.

string = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'

CodePudding user response:

did you mean this?

string = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'
print(list(string))

CodePudding user response:

I guess all you need to do is split after 2 characters.

string = '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'
n = 2
l = [string[i:i   n] for i in range(0, len(string), n)]

To convert it to an integer use

l = [int(string[i:i   n], 16) for i in range(0, len(string), n)]
  • Related