-1

I have a string in Python which represents a hex val

my_hex_str = "000004fc"

How do I convert it into an int ? 04fc = 1276 in DEC

Tried

my_dec = int(my_hex_str)

But did not work, it gives me

ValueError: invalid literal for int() with base 10: '000004fc'
D_A_8
  • 9
  • 4

1 Answers1

2

Specify the base:

>>> int("000004fc", 16)
1276
not_speshal
  • 22,093
  • 2
  • 15
  • 30