OpenResty判断是否为空
OpenRestyLua大约 268 字注意
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
阅读 807 · 发布于 2020-04-11
————        END        ————
扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看换一批
- Elasticsearch后台启动阅读 441
- 走进Rust:结构体阅读 322
- java.sql.SQLException: ORA-01000: maximum open cursors exceeded阅读 558
- OpenResty解析JSON中的null字段时问题阅读 444
- Notepad++的HexEditor插件下载安装阅读 1681
- PostgreSQL别名大小写问题阅读 431
- Android ListView条目点击变色阅读 395
- Redis最大内存策略阅读 382
- Spring Boot JPA设置字段unsigned阅读 1073
- Android ListView数据集为空时显示的视图阅读 389