Skip to content

Instantly share code, notes, and snippets.

@iamucil
Created December 4, 2018 16:02
Show Gist options
  • Save iamucil/5b9aa3f150ca36d0d35cc95de5efab2e to your computer and use it in GitHub Desktop.
Save iamucil/5b9aa3f150ca36d0d35cc95de5efab2e to your computer and use it in GitHub Desktop.
python string conversion, string to int and vice versa
inp = input("Identifier: ")
try:
val = int(inp)
print('%x' % val)
except ValueError:
print(int(inp, 16))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment