【发布时间】:2018-05-22 07:38:42
【问题描述】:
我是 Lua 的新手,所以请多多包涵。我在 Lua 中有 2 个 csv 字符串
a= '1,2,3,4,5'
表示索引 和
b='this,needs,to,be,matched:with,every,single,row,here:'
行由':'字符而不是换行符分隔
预期输出
1,this,2,needs,3,to,4,be,5,matched
1,with,2,every,3,single,4,row,5,here
我尝试使用以下代码分别迭代它们
local result= {}
local u = unpack or table.unpack
for values in string.gmatch(values_csv, '([^:]+)') do
local data = {}
for column1,column2 in string.gmatch(values, '([^,]+)'),string.gmatch(keys, '([^,]+)') do
print(column1, column2)
end
end
由于某种原因,第二个总是为零。如果没有外部库,我在 Lua 中找不到类似于 Python 的 zip 函数。我如何同时迭代两者。感谢您的帮助
【问题讨论】: