我正在尝试遍历URL列表并继续遇到麻烦。具体来说,由于等号,我一直遇到参数问题。
set loadval[1]="/orders/counts"
set loadval[2]="/orders/counts?aggregationKind=Day&fullHistory=true"
set loadval[3]="/products/popularity?aggregationKind=Month&aggregationCount=12"
set loadval[4]="/products/popularity/aggregated?aggregationKind=Month&aggregationCount=12"
for /F "tokens=4 delims==" %%s in ('set loadval[') do (
echo Connecting to %%s
)
想法?
答案 0 :(得分:4)
您的tokens=4
值错误。在set loadval[
命令中,显示的值与这些值类似:
loadval[1]="/orders/counts"
loadval[2]="/orders/counts?aggregationKind=Day&fullHistory=true"
loadval[3]="/products/popularity?aggregationKind=Month&aggregationCount=12"
loadval[4]="/products/popularity/aggregated?aggregationKind=Month&aggregationCount=12"
如果您想在等号之后处理值,那么在第一个之后的标记由=
分隔:
for /F "tokens=1* delims==" %%s in ('set loadval[') do (
echo Connecting to %%t
)
答案 1 :(得分:0)
这是我做的:
setlocal enabledelayedexpansion
set loadval[1]="/orders/counts"
set loadval[2]="/orders/counts?aggregationKind=Day&fullHistory=true"
set loadval[3]="/products/popularity?aggregationKind=Month&aggregationCount=12"
set loadval[4]="/products/popularity/aggregated?aggregationKind=Month&aggregationCount=12"
for /L %%a in (1,1,4) do (
call echo Connecting to !loadval[%%a]!
)
希望这有助于其他人。