Reputation: 267
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!
Upvotes: 3
Views: 2980
Reputation: 342273
try:
i = int(sys.argv[1], 16)
except Exception,e:
print e
else:
# carry on
Upvotes: 0