在eclipse中设置运行参数

# coding=utf-8
'''
Created on 2017年2月16日

@author: chenkai
'''
from sys import argv
script, first, second, third = argv
print 'The script is called:',  script
print 'Your first variable is:',  first
print 'Your second variable is:',  second
print 'Your third variable is:',  third

eclipse中写python代码,用这个argv需要设置运行参数:
打开你要运行的类,随便在哪个地方右击,然后指针放到Run As上,应该出来菜单选项,一般不要参数的直接点Run As Java Application就可以了,有参数的就选下面的Run Configurations,在弹出的窗口里点到Argument页签,在该标签中输入你想设置的命令行参数,多个参数之间用空格隔开,注意如果参数本身有空格,必须将参数加双引号。

方式二:
cdm:进入当前运行文件的所在目录 (cd XXX)
python 文件名.py a b c
直接在后面加上三个参数

猜你喜欢

转载自st4024589553.iteye.com/blog/2357410