zoukankan      html  css  js  c++  java
  • lua io.read()

    io.read(...)

    从文件中读取内容,还有另外一种写法就是 file:read()

    后面可以跟的读取方式有:

    (1) "n"  读取一个数字,这是唯一一个返回数字而不是字符串的格式

    (2) "a"  从当前位置开始剩余的所有字符串,如果在文件末尾,则返回空串""

    (3) "l"  读取下一行内容,如果在文件末尾,则会返回nil

    eg:

    function action_bandwidth(iface)
            luci.http.prepare_content("application/json")

            local bwc = io.popen("luci-bwc -i %q 2>/dev/null" % iface)
            if bwc then
                    luci.http.write("[")

                    while true do
                            local ln = bwc:read("*l")
                            if not ln then break end
                            luci.http.write(ln)
                    end

                    luci.http.write("]")
                    bwc:close()
            end
    end

    在串口掉好用 luci-bwc 命令可得:

  • 相关阅读:
    sqlserver 2005 数据库的差异备份与还原
    sqlserver安装教程
    hibernate左连接查询时在easyUI的dataGrid中有些行取值为空的解决办法
    解释器模式
    命令模式
    责任链模式
    3Sum Closest
    3sum
    代理模式
    外观模式
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/8066789.html
Copyright © 2011-2022 走看看