OpenResty 判断是否为空
OpenResty Lua About 269 words注意
Lua中只有nil和false为假,其余都为真,空字符串也为真。
判断变量为空
local str = nil
-- local str = false
if str then
    -- 不为空的情况
end
if not str then
    -- 为空的情况
end
判断字符串非空
方式一:判断长度大于0
local str = ""
if str and #str > 0 then
end
方式二:判断不等于空
local str = ""
if str and str ~= "" then
end
                Views: 7,436 · Posted: 2020-04-11
            
            ————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
        Loading...