Access command line arguments
Reversing and Printing Command-Line Arguments
Command-line arguments are placed in the list sys.argv
,
with the name of the Python script as sys.argv[0]
.
# reverseargs.py # w ww. j a v a 2 s . com
import sys
args = sys.argv[1:]
print sys.argv
print sys.argv[1]
args.reverse()
print ' '.join(args)