Lua中的收集数据

时间:2015-06-03 19:34:49

标签: file lua

我对编写Lua相对较新,但这应该是一个相对简单的解决方案。

我正在对打印的数据进行分析。我希望能够保存打印在文件上的数据,可能是记事本,这样就不会在文件上打印值存储了。例如:

if VariableOne == nil and VariableTwo ~= nil and VariableThree == true then
    if VariableTime == nil then
        VariableTime = GetTime()
    end
    else if VariableTime ~= nil then
        print("Variable values have been met for "..GetTime() - VariableTime)
        VariableTime = nil
    end
end

我希望它以列表的方式收集计时器,以便我可以在excel中使用:

34.2
43.3
12.2
45.7
...

1 个答案:

答案 0 :(得分:0)

如果要将数据写入文件,请打开文件并写入数据:

local f = assert(io.open('output.txt', 'w'))
f:write(tostring(GetTime() - VariableTime) .. '\n')
-- write more data
f:close()

有关详情,请参阅PiL: The I/O Library