Python 2.7.9 Demo - 获取调用的参数

 

#coding=utf-8

#!/usr/bin/python



import sys;



print("The command line parameters are : ");

for i in range(0, len(sys.argv)) :

        print str(i) + ' -> ' + sys.argv[i];

 

日志

D:\python27_workspace>python 030.01.获取命令行参数.py param1 param2 param3 param4 param5

The command line parameters are :

0 -> 030.01.获取命令行参数.py

1 -> param1

2 -> param2

3 -> param3

4 -> param4

5 -> param5

 

你可能感兴趣的:(python)