小编Mai*_*are的帖子

批次代码中的数字比较

我在批处理代码中遇到 <、> 和 == 等数字比较的困难。我正在做的是生成一个随机数并使用该答案来做某事,这就是我所写的:

set rand=%random%
set rand=%rand:~1,1% 
If %rand%==9 goto nine
If %rand%>5 goto above 5
If %rand%>1 goto above 1
If %rand%==0 goto zero
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,代码就会关闭。我尝试在被比较的两个对象和不等式之间放置空间,但它仍然不起作用。

请记住,这是 Windows 上的批处理代码。

comparison numbers batch-file inequalities

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

batch-file ×1

comparison ×1

inequalities ×1

numbers ×1