在 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
|
|
忧郁的感冒药 · 写一段shell脚本,打开一个文本文件,文件 ...· 3 年前 · |
|
|
聪明的牛肉面 · Corrigendum,Journal ...· 3 年前 · |
|
|
彷徨的热带鱼 · 基于量子计算的混合深度学习电力系统故障诊断, ...· 3 年前 · |
|
|
健身的毛衣 · GeoTools深入解析:GeoTools概 ...· 3 年前 · |