Argument Printing
#!/usr/bin/python
import sys
print len(sys.argv)
print sys.argv
print sys.argv[1]
name = sys.argv[1]
age = sys.argv[2]
print "My name is ",name, "and age is",age
Output:
[root@mysql Scripts]# python if.py davinder 35
3
['if.py', 'davinder', '35']
davinder
My name is davinder and age is 35
import sys
print len(sys.argv)
print sys.argv
print sys.argv[1]
name = sys.argv[1]
age = sys.argv[2]
print "My name is ",name, "and age is",age
Output:
[root@mysql Scripts]# python if.py davinder 35
3
['if.py', 'davinder', '35']
davinder
My name is davinder and age is 35
Comments
Post a Comment