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)

Thomas Bonini
  • 42,536
  • 29
  • 119
  • 156
2
>>> int('0xFF123456', 16)
4279383126
>>> 
mg.
  • 7,467
  • 1
  • 25
  • 30
0

try this:

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

or

>>>print int("0xFF123456",16)
Prasoon Saurav
  • 88,492
  • 46
  • 234
  • 343