Lua读文件
--遍历文件每一行,然后打印
y = 1
file = ("file_read_and_write.txt" ,"r");
for line in file:lines() do
print(y ..":".. line)
y = y + 1
end
file:close()
Lua写文件
--覆盖文件所有内容,如果没有该文件,会自动创建
gFile = ("file_read_and_write.txt" ,"w");
gFile:write("78090890")
gFile:close()
--追加写文件,如果没有该文件,会自动创建
gFile = ("file_read_and_write1.txt" ,"a");
gFile:write("\nppppppppppp")
gFile:close()