How do I convert hex to decimal in Python?

Total
0
Shares

I have some Perl code where the hex() function converts hex data to decimal. How can I do it on Python?


Solution

If by “hex data” you mean a string of the form

s = "6a48f82d8e828ce82b82"

you can use

i = int(s, 16)

to convert it to an integer and

str(i)

to convert it to a decimal string.

Source: StackOverflow.com

Leave a Reply

Your email address will not be published. Required fields are marked *