Let's look at how to pass arguments to a Python program and how to read and write to a file.
Input and output
Program arguments
We can pass arguments to a program from the command line.
Input:
source_code/appendix_c_python/example14_arguments.py #Import the system library in order to use the argument list. import sys print 'The number of the arguments given is', len(sys.argv),'arguments.' print 'The argument list is ', sys.argv, '.'
Output:
$ python example14_arguments.py arg1 110 The number of the arguments given is 3 arguments. The argument list is ['example14_arguments.py', 'arg1', '110'] .