Skip to content

Instantly share code, notes, and snippets.

@rubenerd
Created November 8, 2014 23:51
Show Gist options
  • Save rubenerd/4b4ecef0d16c2d7e6c0d to your computer and use it in GitHub Desktop.
Save rubenerd/4b4ecef0d16c2d7e6c0d to your computer and use it in GitHub Desktop.
Basic Python string to int, and back
#!/usr/bin/env python
spam = 42
eggs = "24"
## "Casting" form ints and strings
ingredients = spam + int(eggs)
menu = str(spam) + eggs
## Alternative using str method
vikings = spam.__str__() + eggs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment