2

Possible Duplicate:
Convert hex string to int in Python

Hello, I want to use some string like "0xFF123456" as a 32-bit unsigned integer. Please give me some advice. Thanks.

Community
  • 1
  • 1
jozei
  • 39
  • 1
  • 2

3 Answers3

5

a = int("0xFF123456", 0)

If it doesn't have a 0x prefix you could also use:

a = int("FF123456", 16)

Andreas Bonini
  • 44,018
  • 30
  • 122
  • 156
2
>>> int('0xFF123456', 16)
4279383126
>>> 
mg.
  • 7,822
  • 1
  • 26
  • 30
0

try this:

>>>print int("0xFF123456",0)

or

>>>print int("0xFF123456",16)
Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345