Lua 未生成输出文件

Lua is not producing output file

我执行了下面的代码,但它没有创建输出文件(至少在 *.lua 所在的目录中)

 file = io.open("output.txt","w")
io.output(file)
io.write("hello, reader!")
io.close(file)

我正在 Windows 上使用 ZeroBrane Studio,如果有帮助的话

该文件将创建在您当前所在的项目目录中。

打开 lua 文件后,您可以在 ZBS 中单击 Set project directory from current file 按钮。

顺便说一句,另一种看起来更简洁的写入文件的方法是使用文件上的方法,比如

file = io.open("output.txt","w")
file:write("hello, reader!")
file:close()

它做同样的事情,但看起来更漂亮。