views:

141

answers:

2

hi I get user argv from command line as follows: '0x000aff00'

and I want python to treat it as hex directly...

str = sys.argv[1]

how is it possible? thanks!

+2  A: 

Try: i = int(sys.argv[1], 16)

Aaron Digulla
A: 
try:
    i = int(sys.argv[1], 16)
except Exception,e:
    print e
else:
    # carry on