Mike Mike - 4 months ago 25
Python Question

How to convert hex string to integer in Python?

How to convert

x = "0x000000001" # hex number string


to

y = "1"

Answer

You can do:

y = int("0x000000001", 16)

in your case:

y = int(x, 16)

Looks like you want the int converted to string:

y = str(int(x, 16))