Lua中打印表格

我有一个Lua脚本并且我需要打印变量res,但我不知道如何打印。我在另一个函数中得到了函数的结果,我想在那里做打印

function parseCSVLine(line)
  local res = {}
  local pos = 1
  local sep = ','
  while true do
     local c = string.sub(line,pos,pos)
     if (c == "") then break end
     if (c == '"') then
        -- 引用值(忽略内部分隔符)
        local txt = ""
        repeat
           local startp,endp = string.find(line,'^%b""',pos) -- 数字
           txt = txt..string.sub(line,startp+1,endp-1)
           pos = endp + 1
           c = string.sub(line,pos,pos)
           if (c == '"') then txt = txt..'"' end
           -- 检查引号之后的第一个字符,如果它是另一个引用字符串而没有分隔符,则将其附加
           -- 这是在引用中“转义”引号字符的方式。示例:
           --   value1,"blub""blip""boing",value3 会在中间生成blub"blip"boing
        until (c ~= '"')
        table.insert(res,txt)
--        assert(c == sep or c == "")
        pos = pos + 1
     else
        -- 没有使用引号,只需查找第一个分隔符
        local startp,endp = string.find(line,sep,pos)
        if (startp) then
           table.insert(res,string.sub(line,pos,startp-1))
           pos = endp + 1
        else
           -- 没有找到分隔符->使用其余的字符串并终止
           table.insert(res,string.sub(line,pos))
           break
        end
     end
  end
  return res
end

例子

local result = parseCSVLine(line)

在这里我想打印结果

点赞
用户107090
用户107090

parseCSVLine 函数中的 res 似乎是作为列表创建的。 所以尝试这样做:

for i,v in ipairs(result) do print(i,v) end 
2017-12-05 14:37:13