相关文章推荐
爱运动的上铺  ·  教程合集 | ...·  1 年前    · 
冲动的树叶  ·  解决Android ...·  2 年前    · 
有爱心的海龟  ·  Vue ...·  2 年前    · 

lua 文件是否存在

在 Lua 中,可以使用 lua 函数 io.open() 来检查文件是否存在。如果文件存在,io.open() 将返回文件句柄;如果文件不存在,它将返回 nil。

代码示例:

local file = io.open("filename.lua", "r")
if file then
   -- file exists
   io.close(file)
   -- file does not exist
        beyond__devil