这很容易(或者应该),但我可能有一个理解的问题。
然而:
我有一个简单的文件,里面有两个数字:0和1
这个片段是:
set adp=
for /f %%i in (file.txt) do (
set adp=%%i
call :test
)
:test
echo ADP %adp%所以我希望结果是
ADP 0
ADP 1
但我得到
ADP 0
ADP 1
ADP 1
为什么我要得到三个结果而不是两个呢?
发布于 2015-06-01 09:13:05
因为无论发生什么,批处理文件都会在循环之后转到:test。
你应该这样做:
set adp=
for /f %%i in (file.txt) do (
set adp=%%i
call :test
)
goto :end
:test
echo ADP %adp%
:endhttps://stackoverflow.com/questions/30569660
复制相似问题