Answers for "sys.argv multiple arguments linux"

11

read argument from terminal

#!/usr/bin/python

import sys

print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)

#Terminal
# $ python test.py arg1 arg2 arg3

#print
#Number of arguments: 4 arguments.
#Argument List: ['test.py', 'arg1', 'arg2', 'arg3']
Posted by: Guest on May-22-2020
9

python arguments

import sys

print ("the script has the name %s" % (sys.argv[0])
Posted by: Guest on November-18-2019

Code answers related to "sys.argv multiple arguments linux"

Python Answers by Framework

Browse Popular Code Answers by Language