本帖最后由 aloha20200628 于 2024-8-29 12:20 编辑
回复 1# qw123456
逐行读取1.txt文件并统计每行中包含字符 a 的个数(不区分大小写)
- @echo off &setlocal
- for /f "delims=" %%a in (1.txt) do (
- echo,%%a>0.0&for %%v in (0.0) do set "v1=%%~zv"
- setlocal enabledelayedexpansion &set "s=%%a" &set "s=!s:a=!"
- echo,!s!>0.0&for %%v in (0.0) do set "v2=%%~zv"
- set/a "v=v1-v2" &echo,本行包含字符 a 的数量 = !v!&endlocal
- )
- del/q "0.0"&endlocal&pause&exit/b
复制代码
|