'如果字符串不相等'在AutoIt中没有按照我的期望工作。

问题描述 投票:1回答:1

我在AutoIt(v3.3.8.1)中写了这段代码。

$x = 'dog'
if not $x = 'hello' Then
   ConsoleWrite("fish")
Else
   ConsoleWrite("world")
EndIf

你不觉得输出应该是 "鱼 "吗?但它却说 "世界"。怎么了?

string operators autoit
1个回答
3
投票

这是因为 操作者优先. 与其他语言,如BASIC和Perl相反,在AutoIt中。not 具有比平等更高的优先权。将代码改为

if not ($x = 'hello') then

if $x <> 'hello' then
© www.soinside.com 2019 - 2024. All rights reserved.