【发布时间】:2018-07-01 17:01:48
【问题描述】:
@echo off
set /a hlo=Hello
:start
echo %hlo%
pause
set /a hlo=%hlo% + World
goto start
pause
我想让hlo 变成“HelloWorld”。
【问题讨论】:
标签: batch-file environment-variables
@echo off
set /a hlo=Hello
:start
echo %hlo%
pause
set /a hlo=%hlo% + World
goto start
pause
我想让hlo 变成“HelloWorld”。
【问题讨论】:
标签: batch-file environment-variables
只需删除/a
set "hlo=Hello"
set "hlo=%hlo% World"
因为set /a 是用来做算术而不是字符串操作
set /?
...
Two new switches have been added to the SET command:
SET /A expression
SET /P variable=[promptString]
The /A switch specifies that the string to the right of the equal sign
is a numerical expression that is evaluated. The expression evaluator
is pretty simple and supports the following operations, in decreasing
order of precedence:
...
【讨论】: