import sysprint "the script name is ", sys.argv[0]for num in range(1, len(sys.argv)): print "parameter %d is %s "% (num, sys.argv[num])
结果如下:
python test2.py this is a test last_parameter_Successthe script name is test2.pyparameter 1 is this parameter 2 is is parameter 3 is a parameter 4 is test parameter 5 is last_parameter_Success