跳到主要内容

读取文件为行数组 (LCC.web_file.get_lines)

声明

lines, err = LCC.web_file.get_lines(path, timeout?)

参数

  • path
    字符串型,要读取的文件路径
  • timeout
    数值型,可选;请求超时时间(秒),默认 60

返回值

  • lines
    表类型,文件内容按行组成的数组(统一换行符为 \n);失败时为 nil
  • err
    字符串型或 nil,失败时的错误描述

说明

读取文件全部内容并按行拆分为数组。
读取前会先把 \r\n 统一转换为 \n

示例

local lines, err = LCC.web_file.get_lines("/配置/list.txt")
if not lines then
error(err)
end
print("共有", #lines, "行")