在 Julia 中访问命令行参数 [英] Access command line arguments in Julia

查看:12
本文介绍了在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆