arguments Printing
#!/usr/bin/python
import sys
print len(sys.argv)
print sys.argv
print sys.argv[1]
Output:
[root@mysql Scripts]# python if.py 3 3
3
['if.py', '3', '3']
3
[root@mysql Scripts]# python if.py 5 3
3
['if.py', '5', '3']
5
[root@mysql Scripts]# python if.py davinder singh
3
['if.py', 'davinder', 'singh']
davinder
import sys
print len(sys.argv)
print sys.argv
print sys.argv[1]
Output:
[root@mysql Scripts]# python if.py 3 3
3
['if.py', '3', '3']
3
[root@mysql Scripts]# python if.py 5 3
3
['if.py', '5', '3']
5
[root@mysql Scripts]# python if.py davinder singh
3
['if.py', 'davinder', 'singh']
davinder
Comments
Post a Comment