命令行 – 交互式lua:命令行参数

我想做
lua prog.lua arg1 arg2

从命令行

里面prog.lua,我想说,例如

print (arg1,arg2,'\n')

Lua似乎没有argv [1]等等,我看到的处理命令行参数的方法似乎是不成熟和/或繁琐。我缺少什么?

解决方法

你缺少arg向量,它在arg [1],arg [2]等中有你想要的元素:
% lua -i -- /dev/null one two three
Lua 5.1.3  copyright (C) 1994-2008 Lua.org,PUC-Rio
> print(arg[2])
two
>

更多信息在Lua manual section on Lua standalone(感谢万里!)。

相关文章

1.github代码实践源代码是lua脚本语言,下载th之后运行thmai...
此文为搬运帖,原帖地址https://www.cnblogs.com/zwywilliam/...
Rime输入法通过定义lua文件,可以实现获取当前时间日期的功能...
localfunctiongenerate_action(params)localscale_action=cc...
2022年1月11日13:57:45 官方:https://opm.openresty.org/官...
在Lua中的table(表),就像c#中的HashMap(哈希表),key和...