gpt4 book ai didi

batch-file - IF "71"GTR "7000"产生 true

转载 作者:行者123 更新时间:2023-12-02 00:27:51 28 4
gpt4 key购买 nike

根据我的代码,如果%~1大于7000,则转到ExceedError

IF "%~1" GTR "7000" GOTO ExceedError

ExceedError 的内容:

ECHO Value exceeded the maximum value. See help file.
EXIT /B

但是这发生了:

...modules>If "71" GTR "7000" GOTO ExceedError

...modules>Echo Value exceeded the maximum value. See help file.
Value exceeded the maximum value. See help file.

...modules>exit /B

发生了什么事?有什么问题吗?

最佳答案

您用双引号将参数括起来,这会强制进行字符串比较。要比较数字,请尝试不使用引号:

IF %~1 GTR 7000 GOTO ExceedError

如果您想防止错误,您可以再添加一行:

set /a "_number=%~1" >nul 2>&1 || set "_number=0"
IF %_number% GTR 7000 GOTO ExceedError

如果输入错误,您会将这些值与作为默认值的 0 进行比较。如果需要,您可以更改它

关于batch-file - IF "71"GTR "7000"产生 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53059990/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com