Created
October 31, 2015 19:51
-
-
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!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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