一.简单模式
读:
file = io.open("test.lua", "r")
io.input(file)
print(io.read())
io.close(file)
写:
file = io.open("test.lua", "a")
io.output(file)
io.write("-- test.lua 文件末尾注释")
io.close(file)
二.安全模式
读:
file = io.open("test.lua", "r")
print(file:read())
file:close()
写:
file = io.open("test.lua", "a")
file:write("--test")
file:close()
两种方式区别在于一个使用io.方式,一个使用的是file:方式