美文网首页
Perl,python和R如何从外部输入参数

Perl,python和R如何从外部输入参数

作者: gtt儿_生物信息学习 | 来源:发表于2019-08-17 10:07 被阅读0次

分别用Perl,python和R从外部输入hello_world.
其中hello_world为从外部输入的参数。

Perl

perl的脚本如下:

print "$ARGV[0]\n";

提交命令:

perl test.pl hello_world

输出结果:

hello_world

python

python的脚本如下:

import sys
print (sys.argv[1])

提交命令:

python test.py hello_world

输出结果:

hello_world

R

R的脚本如下:

args = commandArgs(trailingOnly=TRUE)
print (args[1])

提交命令:

Rscript test.r hello_world

输出结果:

hello_world

需要注意的是Perl默认第一个输入的参数为ARGV[0],从0开始。而python和R都是从1开始。

相关文章

网友评论

      本文标题:Perl,python和R如何从外部输入参数

      本文链接:https://www.haomeiwen.com/subject/lijhsctx.html