Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua if返回false,但应返回true_Lua - Fatal编程技术网

Lua if返回false,但应返回true

Lua if返回false,但应返回true,lua,Lua,所以我有这段代码 for i=1, #result, 1 do local vehicleProps = json.decode(result[i].vehicle) print(vehicleProps.plate) print(plate) if vehicleProps.plate == plate then found = true

所以我有这段代码

 for i=1, #result, 1 do

            local vehicleProps = json.decode(result[i].vehicle)
            print(vehicleProps.plate)
            print(plate)

            if vehicleProps.plate == plate then
                found = true
                print(found)
                break
            end
            print(found)

        end
我得到的输出是

UCF 804 
864539 
false 
65507 
864539 
false 
864539 
864539 
false 
我对Lua相当陌生,但它非常简单,但我无法理解为什么当vehicleProps.plate等于plate时,代码返回false? 有没有办法检查两个值是否相同? 我会感谢这里任何类型的帮助

用户输出:hjpotter92

2162899082 417849 string string false 
QBW 339 417849 string string false 
27538 417849 string string false 
UCF 804 417849 string string false 
417849 417849 string string false 
65507 417849 string string false 
864539 417849 string string false 
9703143430 417849 string string false
将我的代码编辑为:,
看起来里面有一个空格毕竟,谢谢大家的帮助

你是否有机会将数字与字符串进行比较?两者都是字符串是否可能字符串末尾有不可见的字符?例如
\r
您可以在一次调用中打印多个项目<代码>打印(车辆推进板,板,类型(车辆支柱,板),类型(板),车辆推进板=板)<和代码>和检查(可能编辑这个问题的输出)@ HJPOTTE92 DONE请考虑接受答案,所以它将显示解决,谢谢。
function all_trim(s)
                        return s:match( "^%s*(.-)%s*$" )
                    end
                if all_trim(vehicleProps.plate) == all_trim(plate) then