Mike Mike - 1 year ago 158
Python Question

How to convert hex string to integer in Python?

How to convert

x = "0x000000001" # hex number string


y = "1"

Answer Source

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))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download