本帖最后由 apang 于 2015-3-4 18:46 编辑
- @echo off & setlocal enabledelayedexpansion
- for /f "delims=" %%i in (a.txt) do (
- for %%a in (%%i) do (
- set "s=%%a"
- set "s1="
- for /l %%b in (0 1 9) do (
- set n=-1
- for %%c in ("!s:%%b=" "!") do set /a n+=1
- for /l %%c in (1 1 !n!) do set "s1=!s1!%%b"
- )
- set /p=!s1!,<nul
- )
- echo,
- )
- pause
复制代码 发现可以简化:- @echo off & setlocal enabledelayedexpansion
- for /f "delims=" %%i in (a.txt) do (
- for %%a in (%%i) do (
- set "s=%%a"
- set "s1="
- for /l %%b in (0 1 9) do (
- for %%c in ("!s:%%b=" "!") do set "s1=!s1!%%b"
- set "s1=!s1:~,-1!"
- )
- set /p=!s1!,<nul
- )
- echo,
- )
- pause
复制代码
|