标题: [其他] 批处理命令for循环建立变量如何显示? [打印本页]
作者: China_Angel 时间: 2014-4-20 14:05 标题: 批处理命令for循环建立变量如何显示?
- setlocal enabledelayedexpansion
- set num=0
- for /f "delims=;" %%i in (123.txt) do (
- set _!num!=%%i
- set /a num+=1
- echo !_num!
- )
复制代码
像这里的Echo该怎么写才能显示变量的内容?
如果只是echo !_num!的话cmd会显示“ECHO 处于关闭状态。”
作者: xxpinqz 时间: 2014-4-20 15:08
!_num!永远都是空值。- @echo off&setlocal enabledelayedexpansion
- for /f "delims=;" %%i in (123.txt) do (
- set /a num+=1
- set "_!num!=%%i"
- for %%a in (!num!) do echo,!_%%a!
- )
- pause
复制代码
作者: cjiabing 时间: 2014-4-20 17:21
你设置了 num 、 _!num! 两个变量,但你从来没设置!_num!,你又如何 echo !_num!
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |