Oct 22, 2018

[HDGEM] Python Command Line Arguments

Consider the following script i88.ca.py
#!/usr/bin/python    import sys    print 'Number of arguments:', len(sys.argv), 'arguments.'  print 'Argument List:', str(sys.argv)
Now run above script as follows −
$ python  i88.ca.py arg1 arg2 arg3
This produce following result −
Number of arguments: 4 arguments.  Argument List: [' i88.ca.py', 'arg1', 'arg2', 'arg3']  

First argument is always script name and it is also being counted in number of arguments.



--
Posted By Blogger to HDGEM at 1/12/2017 09:51:00 AM