来源:https://www.yisu.com/ask/14177689.html
在Lua中,可以使用==操作符来判断两个字符串是否相等。例如:
local str1 = "hello"
local str2 = "world"
if str1 == str2 then
print("字符串相等")
else
print("字符串不相等")
end
Lua中还提供了string库中的函数来进行字符串比较,例如使用 string.compare
函数:
local str1 = "hello"
local str2 = "world"
if string.compare(str1, str2) == 0 then
print("字符串相等")
else
print("字符串不相等")
end
- 貌似无法使用
if not s1 == s2 then
这样的比较