5# tmplinshi
我用2235行的厚黑学全集试了试(题外话,下载回来都木油看过,原来这玩意就是用来测试的...),结果相差无几
for /f:- @echo off
- echo %time%
- (
- for /f "delims=" %%a in (test.txt) do (
- set str=%%a
- setlocal enabledelayedexpansion
- echo,!str: =_!
- endlocal
- )
- ) >test_2.txt
- echo %time%
- pause
复制代码 回显:- 0:55:30.77
- 0:55:32.83
- 请按任意键继续. . .
复制代码 set /p:- @echo off
- echo %time%
- (
- for /l %%a in (1 1 2235) do (
- setlocal enabledelayedexpansion
- set /p str=
- echo,!str: =_!
- endlocal
- )
- ) <test.txt >test_1.txt
- echo %time%
- pause
复制代码 回显:- 0:55:34.07
- 0:55:36.37
- 请按任意键继续. . .
复制代码 结果是 2.04:2.30,差距约为十分之一...视实际情况而定吧,毕竟遍历方式以及来源的异同决定了这两种用法有各自适用范围~ |