Monday, February 23, 2009

Python: Processing cmd line args

Next thing that you might be interested to learn after the historic "Hello World" program is to know how to process the cmd line arguments.

Method #1: Using sys:


#! /usr/bin/python

import sys;

if __name__ == "__main__":
for args in sys.argv:
print args;




Output:

# cmdLine.py 1 2 3 4
cmdLine.py
1
2
3
4

No comments:

Post a Comment