add arguments python code example
Example 1: read argument from terminal
#!/usr/bin/python
import sys
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
#Terminal
# $ python test.py arg1 arg2 arg3
#print
#Number of arguments: 4 arguments.
#Argument List: ['test.py', 'arg1', 'arg2', 'arg3']
Example 2: python argument parser default value
parser.add_argument("-v", "--verbose", action="store_true",
default="your default value", help="verbose output")