Skip to content

Instantly share code, notes, and snippets.

@Nagasaki45
Created October 31, 2015 19:51
Show Gist options
  • Save Nagasaki45/255e02e2921aaaabeb08 to your computer and use it in GitHub Desktop.
Save Nagasaki45/255e02e2921aaaabeb08 to your computer and use it in GitHub Desktop.
Example for using command line arguments in python. Note that arguments are always string, so cast them to int / floats properly!
import sys
x = int(sys.argv[1])
y = int(sys.argv[2])
print('The result is', x + y)
# usage:
# python using_command_line_arguments.py 5 3
# The result is 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment