Skip to content

Instantly share code, notes, and snippets.

@steveoh
Created April 3, 2017 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveoh/93c0fffb28ac9ea2cef7ba3877360440 to your computer and use it in GitHub Desktop.
Save steveoh/93c0fffb28ac9ea2cef7ba3877360440 to your computer and use it in GitHub Desktop.
get command line args
#!/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