Created
April 3, 2017 19:17
-
-
Save steveoh/93c0fffb28ac9ea2cef7ba3877360440 to your computer and use it in GitHub Desktop.
get command line args
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
#!/usr/bin/env python | |
# * coding: utf8 * | |
''' | |
args.py | |
A module that contains sample code to get params | |
''' | |
import sys | |
if len(sys.argv) > 1: #: run `args.py a b` in the command line | |
#: args were passed to the script get the values | |
param1 = sys.argv[1] #: a | |
param2 = sys.argv[2] #: b | |
else: #: run `args.py` in the command line | |
param1 = raw_input('type something and hit enter to get a value: ') | |
param2 = raw_input('type something and hit enter to get b value: ') | |
print('first value is {}'.format(param1)) | |
print('second value is {}'.format(param2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment