#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    139
    Rep Power
    3

    Converting hex to dec


    Is there a quick way to convert hex to decimal using Python? I can code it out but it would save time to use a one liner.

    thanks
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    606
    Rep Power
    65
    Code:
    hx = "FF"
    
    print(int(hx, 16))  # 255

    Comments on this post

    • Yegers agrees
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    26
    Rep Power
    0
    Code:
    >>> hex = input();print(int(hex, 16))
    Yegers

IMN logo majestic logo threadwatch logo seochat tools logo