看看这个代码- @echo off
- setlocal enabledelayedexpansion
- set /p str=请输入字符串:
- set count=0
- rem 计算字符串长度
- :lp
- set /a count+=1
- for /f %%i in ("%count%") do if not "!str:~%%i,1!"=="" goto lp
-
- rem 定义替换字符
- set _.=chr(46)
- set n=47
- set o=64
- set m=96
- for %%a in (0 1 2 3 4 5 6 7 8 9) do set /a n+=1 & set _%%a=chr(!n!)
- for %%b in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do set /a o+=1 &set _%%b=chr(!o!)
- for %%c in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do set /a m+=1 &set #%%c=chr(!m!)
-
- rem 替换字符
- for /l %%k in (0,1,%count%) do (
- for /f "tokens=1,2 delims=_#=" %%i in ('set _ ^& set #') do (
- if "!str:~%%k,1!"=="%%i" set/p =%%j<nul
- )
- )
- echo.
- pause
复制代码
|