How to convert my hex address?

625 Views Asked by At

I have the following hex number 0x00000000004087b8 and I have to convert this to 0x4087b8 so I would be able to append it to my list. Does anyone have any Idea how can I do this conversion in python?

2

There are 2 best solutions below

0
On

I assume that you have a string, I will recommend doing it like that :

fixed_address = hex(int(address, 16))
1
On

Maybe something like this would work?

hex_num = "0x00000000004087b8"
hex_num = "0x{}".format(hex.split('x')[1].lstrip('0'))