你能用lua复制一个文件吗?这可能吗?您可能会认为只是将"设备"插入到新文件中,但是会在每个循环中创建一个新字符串 - 我没有在此片段中包含该循环.
file = io.open("temp.csv", "a")
file:write(devices)
file = io.open("log.csv", "w")
file:write("")
if (count = 15) then
--copy "temp.csv" to "log.csv"
end
Run Code Online (Sandbox Code Playgroud)
Dou*_*rie 11
有很多方法可以做到这一点.
如果文件足够小,您可以将整个内容读入字符串,并将字符串写入另一个文件:
infile = io.open("temp.csv", "r")
instr = infile:read("*a")
infile:close()
outfile = io.open("log.csv", "w")
outfile:write(instr)
outfile:close()
Run Code Online (Sandbox Code Playgroud)
您也可以调用shell来执行复制,尽管这是特定于平台的:
os.execute("cp temp.csv log.csv")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7430 次 |
| 最近记录: |