function QMPlugin.LinesNumber(FileName) local LinesAllNum = 0 pcall( function() io.input(FileName) while true do local ReadContent = io.read() --注意 lua 中的 nil 需要写为 null if ReadContent == null then break end LinesAllNum = LinesAllNum + 1 end io.close() end) return LinesAllNum end
行数 = File.linesnumber(文件路径) //读取该文本文件的行数