具有多个输出文件的命令行参数

时间:2015-12-13 00:17:24

标签: python file command-line-arguments

如果我想从命令行参数中获取两个输出文件,我可以指定第三个参数吗?即

            infile=sys.argv[1]
            outfile1=sys.argv[2]
            outfile2=sys.argv[3]

然后当我在终端输入命令时:

        python script.py infile.txt outfile1.txt outfield.txt

获得2个输出文件?

1 个答案:

答案 0 :(得分:0)

If you list all the "single" arguments first, you can use the last argument sys.arg[4:], for example, to specify "the rest" of the arguments.