在Julia中访问命令行参数 [英] Access command line arguments in Julia
本文介绍了在Julia中访问命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我输入
$ julia myprog.jl foo bar baz
我可以在代码的哪里访问字符串"foo", "bar", "baz"
?
Where in my code can I go to access the strings "foo", "bar", "baz"
?
我正在寻找sys.argv
推荐答案
啊,更多的网络搜索找到了正确的答案.关键字ARGS::Array{ASCIIString}
包含命令行参数
Ah, more web-searching led to the right answer. The keyword ARGS::Array{ASCIIString}
holds command line arguments
这是一个简单的例子
# cli.jl
print(map(x->string(x, x), ARGS)) # Concatenate each arg onto itself and print
让我们在命令行上对其进行测试:
Lets test it at the command line:
$ julia cli.jl a b c
aa
bb
cc
这篇关于在Julia中访问命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文