在遵循批处理脚本中迭代数组的教程时,我没有得到相同的结果:
@echo off
setlocal enabledelayedexpansion
set topic[0] = comments
set topic[1] = variables
set topic[2] = Arrays
set topic[3] = Decision making
set topic[4] = Time and date
set topic[5] = Operators
for /l %%n in (0,1,5) do (
echo !topic[%%n]!
)
当我运行此命令时,我得到:
答案 0 :(得分:4)
很重要,因为它是一个参数分隔符
set topic[0] = comments
应该是
set topic[0]=comments
cmd奇怪的是变量可以用空格终止
set topic[0] = comments
echo %topic[0] %
comments